![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Reg/SimilarityMeasureMI.h>
GPU implementation of Mutual Information using modern OpenGL. More...
GPU implementation of Mutual Information using modern OpenGL.
This implementation uses the ARB_shader_image_load_store and ARB_compute_shader OpenGL extensions, which is part of the core implementation since OpenGL 4.3. Before using this class, make sure your hardware supports the needed features (i.e. by calling supportedByHardware()).
Public Member Functions | |
SimilarityMeasureMI_GL (SharedImage *img1, SharedImage *img2) | |
Creates a new instance for the two given images. | |
double | compute (const ImageTransformer *t, size_t *overlap=nullptr) override |
Computes and returns the similarity measure. | |
![]() | |
SimilarityMeasureMI (SharedImage *img1, SharedImage *img2) | |
void | setImage1Bins (int bins) |
Sets the number of bins the first images histogram. | |
int | image1Bins () const |
void | setImage2Bins (int bins) |
Sets the number of bins the second images histogram. | |
int | image2Bins () const |
SharedImage * | histogramJoint () |
Returns the joint histogram of both images. | |
void | configure (const Properties *p) override |
Set one or multiple properties. | |
void | configuration (Properties *p) const override |
Retrieve the properties of this object. | |
double | computeEntropy (const TypedImage< unsigned int > &histogram) const |
Computes the Shanon entropy using the histogram. | |
bool | supportsWeights () const override |
Queries the capability whether this similarity measure supports pixel-wise weights. | |
![]() | |
SimilarityMeasureImpl (SharedImage *img1, SharedImage *img2) | |
Sets the two images that should be compared. Does not transfer ownership. | |
virtual bool | setImage1 (SharedImage *img1) |
Replaces the image1 that was set in the constructor with the given image. | |
virtual bool | setImage2 (SharedImage *img2) |
Replaces the image2 that was set in the constructor with the given image. | |
virtual SharedImage * | image1 () const |
virtual SharedImage * | image2 () const |
void | enableImage1Mask (bool enable) |
Specify whether a mask on the first image shall be used if available (true by default) | |
void | enableImage2Mask (bool enable) |
Specify whether a mask on the second image shall be used if available (true by default) | |
virtual void | setWeights (const SharedImage *weights1, const SharedImage *weights2) |
Sets the images to use as weights for the similarity metric. | |
bool | image1MaskEnabled () const |
Return the flag for using the mask of the first image. | |
bool | image2MaskEnabled () const |
Return the flag for using the mask of the second image. | |
![]() | |
virtual void | configureDefaults () |
Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
void | registerParameter (ParameterBase *param) |
Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
void | unregisterParameter (const ParameterBase *param) |
Remove the given Parameter or SubProperty from the list of registered parameters. | |
Configurable (const Configurable &rhs) | |
Configurable (Configurable &&rhs) noexcept | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
Static Public Member Functions | |
static bool | supportedByHardware () |
Checks whether the necessary OpenGL features are supported by the current hardware. | |
![]() | |
static void | defaultConfiguration (Properties *p) |
![]() | |
static void | defaultConfiguration (Properties *p) |
Retrieve the default properties of this class. | |
Protected Member Functions | |
void | updateHistogramSize () override |
void | clearHistograms () |
![]() | |
void | createDebugTexture () |
void | updateRanges () const |
Extracts the value range of the images and sets the m_img1_range and m_img2_range values. | |
![]() | |
template<typename T> | |
double | callTyped (T *obj, const MemImage &img1, const MemImage &img2, const ImageTransformer *t, size_t *overlap=nullptr) |
Helper method to transform the MemImages to TypedImages. | |
void | setMaskIncludeArguments (GL::Program *program) |
Sets all uniforms for SimilarityMeasureMask.glh. | |
void | initMaskInclude (GL::Program *program) |
Initializes the code for the SimilarityMeasureMask.glh code. | |
std::string | glDefines (bool patchBased) const |
Return shared GL program defines for patch-based and weights, used in LNCC and LC2 OpenGL subclasses. | |
Additional Inherited Members | |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
![]() | |
int | m_bins1 |
int | m_bins2 |
SharedImage * | m_histogramJoint |
bool | m_exportJointHistogram |
std::optional< std::pair< double, double > > | m_img1Range |
Value range of the first image. | |
std::optional< std::pair< double, double > > | m_img2Range |
Value range of the second image. | |
![]() | |
SharedImage * | m_img1 |
SharedImage * | m_img2 |
bool | m_useImg1Mask |
bool | m_useImg2Mask |
std::shared_ptr< GlMask::MultiIncludeType > | m_maskImg1 |
std::shared_ptr< GlMask::MultiIncludeType > | m_maskImg2 |
const SharedImage * | m_weights1 |
const SharedImage * | m_weights2 |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
SimilarityMeasureMI_GL | ( | SharedImage * | img1, |
SharedImage * | img2 ) |
Creates a new instance for the two given images.
Both images must be of the same dimensionality.
|
static |
Checks whether the necessary OpenGL features are supported by the current hardware.
Make sure this is the case before relying on this class.
|
overridevirtual |
Computes and returns the similarity measure.
The higher the value the higher the similarity between the two images. The returned value does not need to be normalized, therefore values from different similarity measures should not be compared directly. The computation always iterates each pixel of img1 and compares it to the related pixel of img2. If no ImageTransformer is supplied, the image coordinates of a pixel in img1 are used directly to lookup the value in img2, no transformation is assumed. In this case it's usually advisable that img1 and img2 have the same dimensions, but this is not enforced. If an ImageTransformer is given, it will be used to transfer from img1 pixel coordinates to img2 pixel coordinates including any world transformations. In this case the dimensions of the two images can be unrelated. The optional argument overlap contains the overlap of the two images in pixels.
Implements SimilarityMeasureImpl.
|
overrideprotectedvirtual |
Implements SimilarityMeasureMI.