Loading...
Searching...
No Matches
Filter< GridT, MaskT, InterruptT > Class Template Reference

Volume filtering (e.g., diffusion) with optional alpha masking. More...

`#include <openvdb/tools/Filter.h>`

## Public Types

using | GridType = GridT
using | MaskType = MaskT
using | TreeType = typename GridType::TreeType
using | LeafType = typename TreeType::LeafNodeType
using | ValueType = typename GridType::ValueType
using | AlphaType = typename MaskType::ValueType
using | LeafManagerType = typename tree::LeafManager<TreeType>
using | RangeType = typename LeafManagerType::LeafRange
using | BufferType = typename LeafManagerType::BufferType

## Public Member Functions

| Filter (GridT &grid, InterruptT *interrupt=nullptr)
| Filter (const Filter &other)
| Shallow copy constructor called by tbb::parallel_for() threads during filtering.
int | getGrainSize () const
void | setGrainSize (int grainsize)
| Set the grain-size used for multi-threading.
bool | getProcessTiles () const
void | setProcessTiles (bool flag)
| Set whether active tiles should also be processed.
AlphaType | minMask () const
| Return the minimum value of the mask to be used for the derivation of a smooth alpha value.
AlphaType | maxMask () const
| Return the maximum value of the mask to be used for the derivation of a smooth alpha value.
void | setMaskRange (AlphaType min, AlphaType max)
| Define the range for the (optional) scalar mask.
bool | isMaskInverted () const
| Return true if the mask is inverted, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.
void | invertMask (bool invert=true)
| Invert the optional mask, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.
void | mean (int width=1, int iterations=1, const MaskType *mask=nullptr)
| One iteration of a fast separable mean-value (i.e. box) filter.
void | gaussian (int width=1, int iterations=1, const MaskType *mask=nullptr)
| One iteration of a fast separable Gaussian filter.
void | median (int width=1, int iterations=1, const MaskType *mask=nullptr)
| One iteration of a median-value filter.
void | offset (ValueType offset, const MaskType *mask=nullptr)
void | operator() (const RangeType &range) const
| Used internally by tbb::parallel_for()

## Detailed Description

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>
class openvdb::v11_0::tools::Filter< GridT, MaskT, InterruptT >

Volume filtering (e.g., diffusion) with optional alpha masking.

## Member Typedef Documentation

## AlphaType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using AlphaType = typename MaskType::ValueType

## BufferType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using BufferType = typename LeafManagerType::BufferType

## GridType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using GridType = GridT

## LeafManagerType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using LeafManagerType = typename tree::LeafManager<TreeType>

## LeafType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using LeafType = typename TreeType::LeafNodeType

## MaskType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using MaskType = MaskT

## RangeType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using RangeType = typename LeafManagerType::LeafRange

## TreeType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using TreeType = typename GridType::TreeType

## ValueType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using ValueType = typename GridType::ValueType

## Constructor & Destructor Documentation

## Filter() [1/2]

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

Filter | ( | GridT & | grid,
|  | InterruptT * | interrupt = nullptr )

inline

Constructor

Parameters

  grid | Grid to be filtered.
  interrupt | Optional interrupter.

## Filter() [2/2]

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

Filter | ( | const Filter< GridT, MaskT, InterruptT > & | other | ) |

inline

Shallow copy constructor called by tbb::parallel_for() threads during filtering.

Parameters

  other | The other Filter from which to copy.

## Member Function Documentation

## gaussian()

template<typename GridT, typename MaskT, typename InterruptT>

void gaussian | ( | int | width = 1,
|  | int | iterations = 1,
|  | const MaskType * | mask = nullptr )

One iteration of a fast separable Gaussian filter.

Note
  This is approximated as 4 iterations of a separable mean filter which typically leads an approximation that's better than 95%!

Parameters

  width | The width of the mean-value filter is 2*width+1 voxels.
  iterations | Number of times the mean-value filter is applied.
  mask | Optional alpha mask.

## getGrainSize()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

int getGrainSize | ( |  | ) | const

inline

Returns
  the grain-size used for multi-threading

## getProcessTiles()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

bool getProcessTiles | ( |  | ) | const

inline

Returns
  whether active tiles are being processed

## invertMask()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void invertMask | ( | bool | invert = true | ) |

inline

Invert the optional mask, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.

## isMaskInverted()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

bool isMaskInverted | ( |  | ) | const

inline

Return true if the mask is inverted, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.

## maxMask()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

AlphaType maxMask | ( |  | ) | const

inline

Return the maximum value of the mask to be used for the derivation of a smooth alpha value.

## mean()

template<typename GridT, typename MaskT, typename InterruptT>

void mean | ( | int | width = 1,
|  | int | iterations = 1,
|  | const MaskType * | mask = nullptr )

One iteration of a fast separable mean-value (i.e. box) filter.

Parameters

  width | The width of the mean-value filter is 2*width+1 voxels.
  iterations | Number of times the mean-value filter is applied.
  mask | Optional alpha mask.

## median()

template<typename GridT, typename MaskT, typename InterruptT>

void median | ( | int | width = 1,
|  | int | iterations = 1,
|  | const MaskType * | mask = nullptr )

One iteration of a median-value filter.

Note
  This filter is not separable and is hence relatively slow!

Parameters

  width | The width of the mean-value filter is 2*width+1 voxels.
  iterations | Number of times the mean-value filter is applied.
  mask | Optional alpha mask.

## minMask()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

AlphaType minMask | ( |  | ) | const

inline

Return the minimum value of the mask to be used for the derivation of a smooth alpha value.

## offset()

template<typename GridT, typename MaskT, typename InterruptT>

void offset | ( | ValueType | offset,
|  | const MaskType * | mask = nullptr )

Offsets (i.e. adds) a constant value to all active voxels.

Parameters

  offset | Offset in the same units as the grid.
  mask | Optional alpha mask.

## operator()()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void operator() | ( | const RangeType & | range | ) | const

inline

Used internally by tbb::parallel_for()

Parameters

  range | Range of LeafNodes over which to multi-thread.

Warning
  Never call this method directly!

## setGrainSize()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void setGrainSize | ( | int | grainsize | ) |

inline

Set the grain-size used for multi-threading.

Note
  A grain size of 0 or less disables multi-threading!

## setMaskRange()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void setMaskRange | ( | AlphaType | min,
|  | AlphaType | max )

inline

Define the range for the (optional) scalar mask.

Parameters

  min | Minimum value of the range.
  max | Maximum value of the range.

Mask values outside the range are clamped to zero or one, and values inside the range map smoothly to 0->1 (unless the mask is inverted).

Exceptions

  ValueError | if min is not smaller than max.

## setProcessTiles()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void setProcessTiles | ( | bool | flag | ) |

inline

Set whether active tiles should also be processed.

Note
  If true, some tiles may become voxelized

Warning
  If using with a mask, ensure that the mask topology matches the tile topology of the filter grid as tiles will not respect overlapping mask values at tree levels finer than themselves e.g. a leaf level tile will only use the corresponding tile ijk value in the mask grid