ImFusion C++ SDK 4.4.0
ImFusion::SimilarityMeasureImpl Class Referenceabstract

#include <ImFusion/Reg/SimilarityMeasureBase.h>

Base class of a similarity measure between two images. More...

Inheritance diagram for ImFusion::SimilarityMeasureImpl:

Detailed Description

Base class of a similarity measure between two images.

A similarity measure computes an estimated similarity between two images. Derived classes must provide the actual computation of the similarity value and should either use a pure CPU or a GPU implementation (see also SimilarityMeasureFactory) If a derived class implements its own configurable methods it should always call the one from the base class as well.

Public Member Functions

 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 bool supportsWeights () const =0
 Queries the capability whether this similarity measure supports pixel-wise weights.
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.
void configure (const Properties *p) override
 Set one or multiple properties.
void configuration (Properties *p) const override
 Retrieve the properties of this object.
Public Member Functions inherited from ImFusion::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
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Static Public Member Functions

static void defaultConfiguration (Properties *p)
 Retrieve the default properties of this class.

Protected Member Functions

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

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 ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ SimilarityMeasureImpl()

ImFusion::SimilarityMeasureImpl::SimilarityMeasureImpl ( SharedImage * img1,
SharedImage * img2 )

Sets the two images that should be compared. Does not transfer ownership.

During the livetime of this similarity measure, both images are allowed to change there content but NOT their size, type or number of channels.

Member Function Documentation

◆ setImage1()

virtual bool ImFusion::SimilarityMeasureImpl::setImage1 ( SharedImage * img1)
virtual

Replaces the image1 that was set in the constructor with the given image.

img1 must have the same size and type as the current image1. The content is allowed to be different. Returns true if the image could be set or false otherwise (in which case nothing changes)

Reimplemented in ImFusion::SimilarityMeasureWrapper.

◆ setImage2()

virtual bool ImFusion::SimilarityMeasureImpl::setImage2 ( SharedImage * img2)
virtual

Replaces the image2 that was set in the constructor with the given image.

img2 must have the same size and type as the current image2. The content is allowed to be different. Returns true if the image could be set or false otherwise (in which case nothing changes)

Reimplemented in ImFusion::SimilarityMeasureWrapper.

◆ compute()

virtual double ImFusion::SimilarityMeasureImpl::compute ( const ImageTransformer * t,
size_t * overlap = nullptr )
pure virtual

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.

Implemented in ImFusion::SimilarityMeasureDotProduct, ImFusion::SimilarityMeasureImplHistBased, ImFusion::SimilarityMeasureLC2_CPU, ImFusion::SimilarityMeasureLC2_GPU, ImFusion::SimilarityMeasureLNCC_CPU, ImFusion::SimilarityMeasureLNCC_GL, ImFusion::SimilarityMeasureMI_CPU, ImFusion::SimilarityMeasureMI_GL, ImFusion::SimilarityMeasureML, ImFusion::SimilarityMeasurePixelWise_CPU, ImFusion::SimilarityMeasurePixelWise_GL, ImFusion::SimilarityMeasureSSIM_CPU, ImFusion::SimilarityMeasureSSIM_GL, and ImFusion::SimilarityMeasureWrapper.

◆ supportsWeights()

◆ setWeights()

virtual void ImFusion::SimilarityMeasureImpl::setWeights ( const SharedImage * weights1,
const SharedImage * weights2 )
virtual

Sets the images to use as weights for the similarity metric.

Setting weights only has effect if the similarity measure supports weights.

See also
supportsWeights()

Reimplemented in ImFusion::SimilarityMeasureDotProduct, ImFusion::SimilarityMeasureLC2_GPU, ImFusion::SimilarityMeasureLNCC_GL, ImFusion::SimilarityMeasurePixelWise_GL, and ImFusion::SimilarityMeasureWrapper.

◆ configure()

void ImFusion::SimilarityMeasureImpl::configure ( const Properties * p)
overridevirtual

◆ configuration()

void ImFusion::SimilarityMeasureImpl::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 ImFusion::Configurable.

Reimplemented in ImFusion::SimilarityMeasureImplHistBased, ImFusion::SimilarityMeasureImplPixelWise, ImFusion::SimilarityMeasureLC2, ImFusion::SimilarityMeasureLNCC, ImFusion::SimilarityMeasureMI, ImFusion::SimilarityMeasureML, ImFusion::SimilarityMeasureSSIM, and ImFusion::SimilarityMeasureWrapper.

◆ defaultConfiguration()

void ImFusion::SimilarityMeasureImpl::defaultConfiguration ( Properties * p)
static

Retrieve the default properties of this class.

This includes all properties that are set in configuration.

◆ callTyped()

template<typename T>
double ImFusion::SimilarityMeasureImpl::callTyped ( T * obj,
const MemImage & img1,
const MemImage & img2,
const ImageTransformer * t,
size_t * overlap = nullptr )
protected

Helper method to transform the MemImages to TypedImages.

This method will a method in T with the following signature and name (the name must match exactly!) template<typename V, typename U> double computeTyped(const TypedImage<V> &img1, const TypedImage<U> &img2, const ImageTransformer* t); V and U are the type of the MemImage img1 and img2 respectively.

◆ initMaskInclude()

void ImFusion::SimilarityMeasureImpl::initMaskInclude ( GL::Program * program)
protected

Initializes the code for the SimilarityMeasureMask.glh code.

Subclasses that support mask should call this after creating the initial program. Also has to be called everytime the Mask type changes, however, it can be assumed that this does not happen during compute.


The documentation for this class was generated from the following file:
  • ImFusion/Reg/SimilarityMeasureBase.h
Search Tab / S to search, Esc to close