CVB++ 14.0
Cvb::Foundation::Correlation Namespace Reference

Namespace for collection of functions that calculate different kinds of correlation values. More...

Enumerations

enum class  CorrelationMethod { SumOfSquareDistances , CorrelationCoefficients , CrossCorrelation }
 Correlation calculation methods. More...
 

Functions

std::unique_ptr< ImageCorrelate (const ImagePlane &imagePlane, const ImagePlane &templatePlane, Rect< int > aoi, CorrelationMethod method)
 Calculate the correlation between a plane and a template using a selectable calculation method. More...
 
std::unique_ptr< ImageCorrelate (const ImagePlane &imagePlane, const ImagePlane &templatePlane, CorrelationMethod method)
 Calculate the correlation between a plane and a template using a selectable calculation method. More...
 
std::unique_ptr< ImageCorrelate (const ImagePlane &imagePlane, const ImagePlane &templatePlane, Rect< int > aoi)
 Calculate the correlation between a plane and a template. More...
 
std::unique_ptr< ImageCorrelate (const ImagePlane &imagePlane, const ImagePlane &templatePlane)
 Calculate the correlation between a plane and a template. More...
 
std::vector< LocalMaximumFindMatches (const ImagePlane &imagePlane, const ImagePlane &templatePlane, double threshold, int locality, Rect< int > aoi, SubPixelMode subPixMode=SubPixelMode::ParabolicFast, Neighborhood subPixRadius=Neighborhood::Use3x3)
 Use the correlation coefficient calculation method to find locations in the input image plane that match the given template. More...
 
std::vector< LocalMaximumFindMatches (const ImagePlane &imagePlane, const ImagePlane &templatePlane, double threshold, int locality, SubPixelMode subPixMode=SubPixelMode::ParabolicFast, Neighborhood subPixRadius=Neighborhood::Use3x3)
 Use the correlation coefficient calculation method to find locations in the input image plane that match the given template. More...
 

Detailed Description

Namespace for collection of functions that calculate different kinds of correlation values.

Remarks
CMake users: Link to imported target CVB::CvbFoundationConvertCorrelation

Enumeration Type Documentation

◆ CorrelationMethod

enum class CorrelationMethod
strong

Correlation calculation methods.

Enumerator
SumOfSquareDistances 

Normalized sum of square distances.

Strictly speaking, this is not a correlation, but the inverse of it (i.e. when looking at the resulting accumulator, dark spots indicate a close match between the image and the template, whereas bright areas indicate image regions, where there is little to no similarity between image and template).

CorrelationCoefficients 

Calculate the normalized correlation coefficients between image and template.

These can be considered a measure of similarity between the input image and the template. Wherever the correlation coefficient is high (maximum is 1.0), image and template are very similar. Where the correlation coefficient approaches zero, the similarities vanish.

CrossCorrelation 

Calculate the cross correlations between image and template.

Function Documentation

◆ Correlate() [1/4]

std::unique_ptr< Image > Correlate ( const ImagePlane imagePlane,
const ImagePlane templatePlane 
)
inline

Calculate the correlation between a plane and a template.

Parameters
[in]imagePlaneImage plane to perform the correlation on.
[in]templatePlaneTemplate plane to perform the correlation with.
Returns
Accumulator image (DataType::Float32Bpp).
Exceptions
Anyexception derived from std::exception including CvbException.

The result of the correlation will be an accumulator image with 32 bit floating point pixels containing the results. Note that the accumulator will be smaller than the input plane, the difference being width (or height) of the template - 1. The template will be anchored at its central pixel (fractional positions cut off). In other words: The pixel (0, 0) of the accumulator corresponds to image position (int)(template width / 2, template height / 2) and its value will be a representation of the correlation between the input image and the template, centered around this very pixel.

◆ Correlate() [2/4]

std::unique_ptr< Image > Correlate ( const ImagePlane imagePlane,
const ImagePlane templatePlane,
CorrelationMethod  method 
)
inline

Calculate the correlation between a plane and a template using a selectable calculation method.

Parameters
[in]imagePlaneImage plane to perform the correlation on.
[in]templatePlaneTemplate plane to perform the correlation with.
[in]methodCorrelation method to use.
Returns
Accumulator image (DataType::Float32Bpp).
Exceptions
Anyexception derived from std::exception including CvbException.

The result of the correlation will be an accumulator image with 32 bit floating point pixels containing the results. Note that the accumulator will be smaller than the input plane, the difference being width (or height) of the template - 1. The template will be anchored at its central pixel (fractional positions cut off). In other words: The pixel (0, 0) of the accumulator corresponds to image position (int)(template width / 2, template height / 2) and its value will be a representation of the correlation between the input image and the template, centered around this very pixel.

◆ Correlate() [3/4]

std::unique_ptr< Image > Correlate ( const ImagePlane imagePlane,
const ImagePlane templatePlane,
Rect< int >  aoi 
)
inline

Calculate the correlation between a plane and a template.

Parameters
[in]imagePlaneImage plane to perform the correlation on.
[in]templatePlaneTemplate plane to perform the correlation with.
[in]aoiArea of interest to perform the correlation on.
Returns
Accumulator image (DataType::Float32Bpp).
Exceptions
Anyexception derived from std::exception including CvbException.

The result of the correlation will be an accumulator image with 32 bit floating point pixels containing the results. Note that the accumulator will be smaller than the input aoi, the difference being width (or height) of the template - 1. The template will be anchored at its central pixel (fractional positions cut off). In other words: The pixel (0, 0) of the accumulator corresponds to image position (int)(template width / 2, template height / 2) and its value will be a representation of the correlation between the input image and the template, centered around this very pixel.

◆ Correlate() [4/4]

std::unique_ptr< Image > Correlate ( const ImagePlane imagePlane,
const ImagePlane templatePlane,
Rect< int >  aoi,
CorrelationMethod  method 
)
inline

Calculate the correlation between a plane and a template using a selectable calculation method.

Parameters
[in]imagePlaneImage plane to perform the correlation on.
[in]templatePlaneTemplate plane to perform the correlation with.
[in]aoiArea of interest to perform the correlation on.
[in]methodCorrelation method to use.
Returns
Accumulator image (DataType::Float32Bpp).
Exceptions
Anyexception derived from std::exception including CvbException.

The result of the correlation will be an accumulator image with 32 bit floating point pixels containing the results. Note that the accumulator will be smaller than the input aoi, the difference being width (or height) of the template - 1. The template will be anchored at its central pixel (fractional positions cut off). In other words: The pixel (0, 0) of the accumulator corresponds to image position (int)(template width / 2, template height / 2) and its value will be a representation of the correlation between the input image and the template, centered around this very pixel.

◆ FindMatches() [1/2]

std::vector< LocalMaximum > FindMatches ( const ImagePlane imagePlane,
const ImagePlane templatePlane,
double  threshold,
int  locality,
Rect< int >  aoi,
SubPixelMode  subPixMode = SubPixelMode::ParabolicFast,
Neighborhood  subPixRadius = Neighborhood::Use3x3 
)
inline

Use the correlation coefficient calculation method to find locations in the input image plane that match the given template.

Parameters
[in]imagePlaneImage plane in which to look for matches.
[in]templatePlaneTemplate to match.
[in]thresholdMinimum correlation coefficient to look for (valid values range from 0 to 1).
[in]localityMinimum distance between two valid matches (measured using the L1 norm).
[in]aoiRegion of interest in which to look for matches.
[in]subPixModeMode to be used for determining sub pixel accuracy (see description of SubPixelMode values).
[in]subPixRadiusNeighborhood to take account in the sub pixel calculation (see description of Neighborhood values).
Returns
List of the local maxima that have been found.
Exceptions
Anyexception derived from std::exception including CvbException.

If the matches fall within the locality distance (measured using the L1 norm), the one with the lower correlation coefficient will be removed from the result list.

◆ FindMatches() [2/2]

std::vector< LocalMaximum > FindMatches ( const ImagePlane imagePlane,
const ImagePlane templatePlane,
double  threshold,
int  locality,
SubPixelMode  subPixMode = SubPixelMode::ParabolicFast,
Neighborhood  subPixRadius = Neighborhood::Use3x3 
)
inline

Use the correlation coefficient calculation method to find locations in the input image plane that match the given template.

Parameters
[in]imagePlaneImage plane in which to look for matches.
[in]templatePlaneTemplate to match.
[in]thresholdMinimum correlation coefficient to look for (valid values range from 0 to 1).
[in]localityMinimum distance between two valid matches (measured using the L1 norm).
[in]subPixModeMode to be used for determining sub pixel accuracy (see description of SubPixelMode values).
[in]subPixRadiusNeighborhood to take account in the sub pixel calculation (see description of Neighborhood values).
Returns
List of the local maxima that have been found.
Exceptions
Anyexception derived from std::exception including CvbException.

If the matches fall within the locality distance (measured using the L1 norm), the one with the lower correlation coefficient will be removed from the result list.