![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/GL/GlHistogram.h>
Provides an interface to calculate the histogram of an image either on the CPU or on the GPU. More...
Provides an interface to calculate the histogram of an image either on the CPU or on the GPU.
The GPU implementation supports two modes:
Usage Example:
Public Types | |
| enum | Device { Device_CPU = 0 , Device_GPU = 1 } |
Public Member Functions | |
| GlHistogram () | |
| Creates a new GlHistogram instance with default settings. | |
Configure Histogram Computation | |
| int | binCount () const |
| Returns the number of histogram bins. | |
| void | setBinCount (int bins) |
| Sets the number of histogram bins. | |
| bool | mergesChannels () const |
| Returns the flag whether to compute a single histogram of the averages over all channels or an individual histogram for each channel. | |
| void | setMergeChannels (bool value) |
| Sets the flag whether to compute a single histogram of the averages over all channels or an individual histogram for each channel. | |
| vec2 | minmaxIntensity () const |
| Returns the minimum/maximum intensity to use during binning. | |
| void | setMinmaxIntensity (vec2 value) |
| Sets the minimum/maximum intensity to use during binning. | |
Run Histogram Computation | |
| bool | update (SharedImage *image, Device device=Device_GPU, bool considerMask=false) |
| Computes the histogram of the provided image and returns true on success. | |
| bool | update (const GlImage *image, const GlMask *mask=nullptr) |
| Computes the histogram of the provided image on the GPU and returns true on success. | |
| bool | update (const MemImage *image, const Mask *mask=nullptr) |
| Computes the histogram of the provided image on the CPU and returns true on success. | |
Access Results of the Computation | |
| const SharedImage * | data () const |
| Returns the histogram data as a 1D float image while maintaining its ownership. | |
| const TypedImage< float > * | typedData () const |
| Returns the histogram data as 1D float image while maintaining its ownership. | |
| std::unique_ptr< SharedImage > | releaseData () |
| Returns the histogram data as a 1D float image and passes ownership of the returned pointer to the caller. | |
| int | pixelCount (int channel=0) const |
| Returns the total amount of pixels (sum of all bins) for the specified channel. | |
| double | entropy (bool normalized=false, int channel=0) |
| Return the image entropy based on the computed histogram. | |
| ImFusion::GlHistogram::GlHistogram | ( | ) |
Creates a new GlHistogram instance with default settings.
| std::runtime_error | if initialization of the OpenGL resources fails. |
| vec2 ImFusion::GlHistogram::minmaxIntensity | ( | ) | const |
Returns the minimum/maximum intensity to use during binning.
If the minmax interval is empty (i.e. min == max) GlHistogram will use the following ranges during binning:
| void ImFusion::GlHistogram::setMinmaxIntensity | ( | vec2 | value | ) |
Sets the minimum/maximum intensity to use during binning.
If the minmax interval is empty (i.e. min == max) GlHistogram will use the following ranges during binning:
| bool ImFusion::GlHistogram::update | ( | SharedImage * | image, |
| Device | device = Device_GPU, | ||
| bool | considerMask = false ) |
Computes the histogram of the provided image and returns true on success.
| image | Input image |
| device | Device to use for computation |
| considerMask | Flag whether to consider a Mask attached to the SharedImage during histogram computation |
Computes the histogram of the provided image on the GPU and returns true on success.
| image | Input image |
| mask | Optional GlMask to consider during during histogram computation |
Computes the histogram of the provided image on the CPU and returns true on success.
| image | Input image |
| mask | Optional Mask to consider during during histogram computation |
| const SharedImage * ImFusion::GlHistogram::data | ( | ) | const |
Returns the histogram data as a 1D float image while maintaining its ownership.
If the object was constructed with mergeChannels set to true, the data will be returned in a single channel image. If the object was constructed with mergeChannels set to false, the data will be returned in a 4-channel image.
| double ImFusion::GlHistogram::entropy | ( | bool | normalized = false, |
| int | channel = 0 ) |
Return the image entropy based on the computed histogram.
| normalized | Normalize result with respect to number of bins (cf. Donath, Beckmann, 2006) |