Foundation (CVFoundation.dll) 14.1
Correlation Functions

## Functions

cvbres_t CalculateCorrelationCoefficients (IMG ImgIn, long IndexIn, IMG Template, long IndexTemplate, long left, long top, long right, long bottom, IMG &Accumulator)
Calculates the normalized correlation coefficient between the source and template image for each possible position. More...

cvbres_t CalculateCrossCorrelations (IMG ImgIn, long IndexIn, IMG Template, long IndexTemplate, long left, long top, long right, long bottom, IMG &Accumulator)
Calculates normalized cross correlations between the source and template image for each possible position. More...

cvbres_t CalculateSumOfSquareDistances (IMG ImgIn, long IndexIn, IMG Template, long IndexTemplate, long left, long top, long right, long bottom, IMG &Accumulator)
Calculates the normalized sum of squared distances (SSD) between the source and template image for each possible position. More...

## Detailed Description

Since
1.0.0 Finished implementation. (VG, 29.07.2005)

## ◆ CalculateCorrelationCoefficients()

 cvbres_t CalculateCorrelationCoefficients ( IMG ImgIn, long IndexIn, IMG Template, long IndexTemplate, long left, long top, long right, long bottom, IMG & Accumulator )

Calculates the normalized correlation coefficient between the source and template image for each possible position.

```The result values are stored in the output image containing 32 bit floating point pixel informations.
The output images may be converted to integer format afterwards using functions like ScaleTo8BPPUnsigned. \n\n
The normalized cross correlation for a given pixel at position (u,v) of the output image is defined as
```

with

I(x,y) denotes the gray value of the image pixel at position (x,y), and T(x,y) the gray-value of the template at position (x,y). The letters with the horizontal bar denote the average over template and image respectively (in case of the image the average over a region of the image equivalent to the size of the template, centered around the coordinate (u,v) is meant). u and v denote the coordinates in in the output image. Note that the size of the output image containing the normalized correlation coefficients is (WI - (WT - 1)) x (HI - (HT - 1)), where WI, HI denote the width and height of the source image, and WT, HT denote the width and height of the template. This in turn means that pixel (0,0) of the output image corresponds to pixel (tplCols-1)/2 and (tplRows-1)/2 (with the decimals cut off).

The higher the value of a pixel in the output image, the higher the similarity between image (at that point) and template. The values for the correlation coefficients range between 0 and 1.

Parameters
 [in] ImgIn Handle of image object. to be searched for the template. [in] IndexIn Index plane in which to search for the template. [in] Template Handle of template object to search for. [in] IndexTemplate Index plane of the template object to be used. [in] left X-coordinate of the left upper corner of the area of interest. [in] top Y-coordinate of the left upper corner of the area of interest. [in] right X-coordinate of the right bottom corner of the area of interest. [in] bottom Y-coordinate of the right bottom corner of the area of interest. [out] Accumulator Image handle of result image. Attention: The image handle must be disposed of by calling ReleaseImage once it is no longer needed.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
CalculateSumOfSquareDistances, CalculateCrossCorrelations
Examples:
Visual C++ - VC Correlation Example

## ◆ CalculateCrossCorrelations()

 cvbres_t CalculateCrossCorrelations ( IMG ImgIn, long IndexIn, IMG Template, long IndexTemplate, long left, long top, long right, long bottom, IMG & Accumulator )

Calculates normalized cross correlations between the source and template image for each possible position.

```The result values are stored in the output image containing 32 bit floating point pixel informations.
The output images may be converted to integer format afterwards using functions like ScaleTo8BPPUnsigned. \n\n
The normalized cross correlation for a given pixel at position (u,v) of the output image is defined as
```

with

I(x,y) denotes the gray value of the image pixel at position (x,y), and T(x,y) the gray-value of the template at position (x,y). u and v denote the coordinates in in the output image. Note that the size of the output image containing the normalized cross correlations is (WI - ((WT - 1)) x (HI - (HT - 1)), where WI, HI denote the width and height of the source image, and WT, HT denote the width and height of the template. This in turn means that pixel (0,0) of the output image corresponds to pixel (tplCols-1)/2 and (tplRows-1)/2 (with the decimals cut off).

The higher the value of a pixel in the output image, the higher the similarity between image (at that point) and template. The values for the normalized cross correlation range between -1 and 1.

Parameters
 [in] ImgIn Handle of image object. to be searched for the template. [in] IndexIn Index plane in which to search for the template. [in] Template Handle of template object to search for. [in] IndexTemplate Index plane of the template object to be used. [in] left X-coordinate of the left upper corner of the area of interest. [in] top Y-coordinate of the left upper corner of the area of interest. [in] right X-coordinate of the right bottom corner of the area of interest. [in] bottom Y-coordinate of the right bottom corner of the area of interest. [out] Accumulator Image handle of result image. Attention: The image handle must be disposed of by calling ReleaseImage once it is no longer needed.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
CalculateSumOfSquareDistances, CalculateCorrelationCoefficients
Examples:
Visual C++ - VC Correlation Example

## ◆ CalculateSumOfSquareDistances()

 cvbres_t CalculateSumOfSquareDistances ( IMG ImgIn, long IndexIn, IMG Template, long IndexTemplate, long left, long top, long right, long bottom, IMG & Accumulator )

Calculates the normalized sum of squared distances (SSD) between the source and template image for each possible position.

```The result values are stored in the output image containing 32 bit floating point pixel informations.
The output images may be converted to integer format afterwards using functions like ScaleTo8BPPUnsigned. \n\n
The normalized sum of square distances for a given pixel at position (u,v) of the output image is defined as
```

with

I(x,y) denotes the gray value of the image pixel at position (x,y), and T(x,y) the gray-value of the template at position (x,y). u and v denote the coordinates in in the output image. Note that the size of the output image containing the normalized SSDs is (WI - ((WT - 1)) x (HI - (HT - 1)), where WI, HI denote the width and height of the source image, and WT, HT denote the width and height of the template. This in turn means that pixel (0,0) of the output image corresponds to pixel (tplCols-1)/2 and (tplRows-1)/2 (with the decimals cut off).

The lower the value of a pixel in the output image, the higher the similarity between image (at that point) and template. The minimum value is of course zero.

Parameters
 [in] ImgIn Handle of image object. to be searched for the template. [in] IndexIn Index plane in which to search for the template. [in] Template Handle of template object to search for. [in] IndexTemplate Index plane of the template object to be used. [in] left X-coordinate of the left upper corner of the area of interest. [in] top Y-coordinate of the left upper corner of the area of interest. [in] right X-coordinate of the right bottom corner of the area of interest. [in] bottom Y-coordinate of the right bottom corner of the area of interest. [out] Accumulator Image handle of result image. Attention: The image handle must be disposed of by calling ReleaseImage once it is no longer needed.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
CalculateCrossCorrelations, CalculateCorrelationCoefficients
Examples:
Visual C++ - VC Correlation Example