ImFusion SDK 4.3
SimilarityMeasureMI Class Referenceabstract

#include <ImFusion/Reg/SimilarityMeasureMI.h>

Computes the Mutual Information of two images. More...

+ Inheritance diagram for SimilarityMeasureMI:

Detailed Description

Computes the Mutual Information of two images.

The marginal entropies of both images are determined by computing the histogram of the images. The number of bins used for these histograms can be set with image1Bins and image2Bins properties. The joint entropy is determined by computing the 2D joint histogram, with image1JointBins in one direction and image2JointBins in the other direction.

If the number of bins does not correspond to the value range of the data type, the bin for each value is determined by:

bin = round((value-min)/(max-min) * (bins-1))

For 8- and 16-bit, the min value is 0 and the max value 256 and 65536 respectively. All other types use the actual min and max value in the image.

See also:

Public Member Functions

 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
 
SharedImagehistogramJoint ()
 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.
 
- Public Member Functions inherited from SimilarityMeasureImpl
 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 SharedImageimage1 () const
 
virtual SharedImageimage2 () 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 double compute (const ImageTransformer *t, size_t *overlap=nullptr)=0
 Computes and returns the similarity measure.
 
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.
 
- Public Member Functions inherited from Configurable
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
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Static Public Member Functions

static void defaultConfiguration (Properties *p)
 
- Static Public Member Functions inherited from SimilarityMeasureImpl
static void defaultConfiguration (Properties *p)
 Retrieve the default properties of this class.
 

Protected Member Functions

virtual void updateHistogramSize ()=0
 
void createDebugTexture ()
 
void updateRanges () const
 Extracts the value range of the images and sets the m_img1_range and m_img2_range values.
 
- Protected Member Functions inherited from SimilarityMeasureImpl
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.
 

Protected Attributes

int m_bins1
 
int m_bins2
 
SharedImagem_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.
 
- Protected Attributes inherited from SimilarityMeasureImpl
SharedImagem_img1
 
SharedImagem_img2
 
bool m_useImg1Mask
 
bool m_useImg2Mask
 
std::shared_ptr< GlMask::MultiIncludeTypem_maskImg1
 
std::shared_ptr< GlMask::MultiIncludeTypem_maskImg2
 
const SharedImagem_weights1
 
const SharedImagem_weights2
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Additional Inherited Members

- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Member Function Documentation

◆ histogramJoint()

SharedImage * histogramJoint ( )

Returns the joint histogram of both images.

The joint histogram is empty before compute is called.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Set one or multiple properties.

The default implementation retrieves the mask mode (param names "maskModeImg1" and "maskModeImg2")

Reimplemented from SimilarityMeasureImpl.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Retrieve the properties of this object.

The default implementation stores the mask mode (param names "maskModeImg1" and "maskModeImg2")

Reimplemented from SimilarityMeasureImpl.

◆ supportsWeights()

bool supportsWeights ( ) const
inlineoverridevirtual

Queries the capability whether this similarity measure supports pixel-wise weights.

Implements SimilarityMeasureImpl.

◆ updateRanges()

void updateRanges ( ) const
protected

Extracts the value range of the images and sets the m_img1_range and m_img2_range values.

Calling this in the constructor may not be enough as the image data can be written after the construction depending on the pre-apply flag.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close