![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/GlReduction.h>
High-performance implementation of a reduction of 2D and 3D images using OpenGL. More...
High-performance implementation of a reduction of 2D and 3D images using OpenGL.
This class provides a set of reduction operators that can be applied to either a GlImage or alternatively an ImageMath::GlExpr. Furthermore, you can apply the reduction to only a subregion of the image or alternatively optionally provide a GlMask to dynamically exclude individual pixels/regions from the reduction.
Usage example:
Public Types | |
enum | ReductionOperator { MIN , MAX , SUM , PRODUCT , AVERAGE , AVERAGE_ABSOLUTE } |
Operation to be performed by reduction. More... | |
Public Member Functions | |
GlReduction (ReductionOperator reductionOperator) | |
Creates a new GlReduction instance using the given reduction oparator in reduce(). | |
GlReduction (GlReduction &&other) noexcept | |
GlReduction & | operator= (GlReduction &&) noexcept |
std::vector< double > | reduce (const GlImage &img, const GlMask *mask=nullptr, std::vector< vec3i > *outArgMinMax=nullptr) |
Reduces the given input image and returns the reduction result for each channel. | |
std::vector< double > | reduce (const ImageMath::GlExpr &expr, const ImageDescriptor &desc, std::vector< vec3i > *outArgMinMax=nullptr) |
Reduces the given input image and returns the reduction result for each channel. | |
std::vector< double > | reduceSubregion (const GlImage &img, const vec3i &subregion, const GlMask *mask=nullptr, std::vector< vec3i > *outArgMinMax=nullptr) |
Reduces the given subregion of the input image and returns the reduction result for each channel. | |
enum ReductionOperator |
Operation to be performed by reduction.
|
explicit |
Creates a new GlReduction instance using the given reduction oparator in reduce().
std::runtime_error | if initialization of the OpenGL resources fails. |
std::vector< double > reduce | ( | const GlImage & | img, |
const GlMask * | mask = nullptr, | ||
std::vector< vec3i > * | outArgMinMax = nullptr ) |
Reduces the given input image and returns the reduction result for each channel.
Result values are normalized intensities as they reside on GPU memory. If you want the original intensity domain convert the result using GlUtils::normalizedToStorage().
img | The input image for the reduction. |
mask | Optional image mask. Only image values under locations with nonzero mask values will be considered for the reduction. |
outArgMinMax | Optional output parameter for returning the argmin/argmax result. If this is a minimum/maximum reduction you will find the channel-wise pixel coordinates of a min/max value. It is undefined which coordinate is returned in case the argmin/argmax is not unique. |
std::runtime_error | if initialization of the OpenGL resources fails. |
std::vector< double > reduce | ( | const ImageMath::GlExpr & | expr, |
const ImageDescriptor & | desc, | ||
std::vector< vec3i > * | outArgMinMax = nullptr ) |
Reduces the given input image and returns the reduction result for each channel.
Returns the original values as provided by expr.
expr | A ImageMath::GlExpr representing any arithmetic expression on images. |
outArgMinMax | Optional output parameter for returning the argmin/argmax result. If this is a minimum/maximum reduction you will find the channel-wise pixel coordinates of a min/max value. It is undefined which coordinate is returned in case the argmin/argmax is not unique. |
std::runtime_error | if initialization of the OpenGL resources fails. |
std::vector< double > reduceSubregion | ( | const GlImage & | img, |
const vec3i & | subregion, | ||
const GlMask * | mask = nullptr, | ||
std::vector< vec3i > * | outArgMinMax = nullptr ) |
Reduces the given subregion of the input image and returns the reduction result for each channel.
Result values are normalized intensities as they reside on GPU memory. If you want the original intensity domain convert the result using GlUtils::normalizedToStorage().
img | The input image for the reduction. |
subregion | Size of the subregion for which to perform the reduction. It is not possible to define an offset: subregion and image will always share the same origin. |
mask | Optional image mask. Only image values under locations with nonzero mask values will be considered for the reduction. |
outArgMinMax | Optional output parameter for returning the argmin/argmax result. If this is a minimum/maximum reduction you will find the channel-wise pixel coordinates of a min/max value. It is undefined which coordinate is returned in case the argmin/argmax is not unique. |
std::runtime_error | if initialization of the OpenGL resources fails. |