Modules | |
Census Correlation | |
Functions | |
F32 | corrcheck (image *a, image *b) |
Calculate Correlation Coefficient for Two Small Images (Floating Point Version). More... | |
I32 | NormalizedCorrelation (image *SearchX, image *Pattern, I32 mode, F32 MinContr, F32 MinCorr, F32 *Contr, F32 *Corr, F32 *PosX, F32 *PosY) |
Normalized Correlation Returning F32 Correlation Value. More... | |
I32 | NormalizedCorrelationI32 (image *src, image *ref, F32 MinContr, I32 *Corr, F32 *Contr, I32 *PosX, I32 *PosY) |
Normalized Correlation Returning I32 Correlation Value. More... | |
I32 | BarCorrV (image *SearchX, image *Pattern, F32 MinContr, I32 *Corr, F32 *Contr, I32 *PosX) |
Normalized Correlation for finding a LINEAR structure in an image. More... | |
I32 | BarCorrV2 (image *SearchX, image *Pattern, F32 MinContr, I32 *Corr, F32 *Contr, I32 *PosX, I32 *PosY) |
Normalized Correlation for finding a LINEAR structure in an image. More... | |
#define | BCV(src, ref, PosX, Corr) BarCorrV(src, ref, 0.0, Corr, NULL, PosX) |
Normalized Correlation for finding a LINEAR structure in an image (Macro). More... | |
#define | BCV2(src, ref, PosX, PosY, Corr) BarCorrV2(src, ref, 0.0, Corr, NULL, PosX, PosY) |
Normalized Correlation for finding a LINEAR structure in an image (Macro). More... | |
#define | NC(src, ref, PosX, PosY, Corr) NormalizedCorrelationI32(src, ref, 0, Corr, NULL, PosX, PosY) |
Normalized Correlation Returning I32 Correlation Position Only (Macro). More... | |
#define NC | ( | src, | |
ref, | |||
PosX, | |||
PosY, | |||
Corr | |||
) | NormalizedCorrelationI32(src, ref, 0, Corr, NULL, PosX, PosY) |
NC() is a macro which calls NormalizedCorrelationI32() with the following arguments: NormalizedCorrelationI32(src, ref, 0, Corr, NULL, PosX, PosY).
#define BCV | ( | src, | |
ref, | |||
PosX, | |||
Corr | |||
) | BarCorrV(src, ref, 0.0, Corr, NULL, PosX) |
BCV() is a macro which calls BarCorrV() with the following arguments: BarCorrV(src, ref, 0.0, Corr, NULL, PosX).
#define BCV2 | ( | src, | |
ref, | |||
PosX, | |||
PosY, | |||
Corr | |||
) | BarCorrV2(src, ref, 0.0, Corr, NULL, PosX, PosY) |
BCV2() is a macro which calls BarCorrV2() with the following arguments: BarCorrV2(src, ref, 0.0, Corr, NULL, PosX, PosY).
The function calculates the normalized gray scale correlation coefficient (NCF) for the two images a
and b
. Both images must have the same size. The calculation is performed with maximum possible accuracy using integer and floating-point calculations internally wherever appropriate. The result is in the range of [-1.0, +1.0]. A value of +1.0 indicates a complete correlation, i.e. identity (except for differences in brightness and contrast). A value of -1.0 also indicates a complete correlation but with inverse contrast. For comparison of the result with correlation coefficients used by the functions vc_corr0() and vc_corr2(), the following conversion may be helpful:
Valid image sizes must comply to kx*
ky
<= 1024, e.g. 32×32 or 16×64.
where corr_result is one element of the destination image dst32
and contr3() is a function that calculates the inverse contrast for the sample image.
The function returns the standard error format, i.e ERR_FORMAT if the sizes of the images are not within the range (e.g. (kernel != image) or (kernel > 1024 pixels)).
a,b | Images to be Compared. |
ERR_FORMAT | if a->st or b->st is NULL. |
ERR_FORMAT | if a->dx/y not equal to b->dx/y or dx/y out of Range [0,65535]. |
ERR_FORMAT | if 1024 < b->dx * b->dy. |
Correlation | on Success. Correlation Value in the Range [-1.0..+1.0]. |
I32 NormalizedCorrelation | ( | image * | SearchX, |
image * | Pattern, | ||
I32 | mode, | ||
F32 | MinContr, | ||
F32 | MinCorr, | ||
F32 * | Contr, | ||
F32 * | Corr, | ||
F32 * | PosX, | ||
F32 * | PosY | ||
) |
This function searches a pattern defined by image Pattern
in the SearchX
image using normalized correlation. A minimum contrast and a minimum correlation value may be specified by the variables MinContr
(set MinContr
= 0 if not needed) and MinCorr
(set MinCorr
= 0 if not needed). If the pattern is found the X- and Y-position is returned as well as the correlation value of the match and the contrast of the image at this position.
This Correlation is done using pixel accuracy if mode
is set to 0, or using two different methods of subpixel interpolation if mode
= 1 or 2. The subpixel precise interpolation has two additional error return values, ERR_SINGULAR and ERR_BOUNDS; in this case result will only be pixel-precise.
The range for the correlation values Corr
is [0.0..1.0]. 0.0 indicates no correlation, 1.0 indicates identity of the found subimage and the pattern (precisely: the subimage is identical to the pattern multiplied with a constant). Correlation values < 0 are not considered and treated as 0. Correlation values < 0 occur if the subimage is the inverse (negative) of the pattern.
SearchX | The Image to be Searched In. |
Pattern | The Reference Pattern. |
MinContr | The Minimum Contrast Requirement, can speed up the Search. |
MinCorr | The Minimum Correlation Requirement, can speed up the Search. |
mode | Choose Subixel Method:
|
Contr | Contrast Value Output, Set to NULL, if not Required. |
Corr | Correlation Value Output, Set to NULL, if not Required. |
PosX | x-Position Output, Set to NULL, if not Required. |
PosY | y-Position Output, Set to NULL, if not Required. |
ERR_FORMAT | if SearchX->dx or SearchX->dy, or Pattern->dx or Pattern->dy are not in Range [0,65535]. |
ERR_FORMAT | if SearchX->dx < Pattern->dx or SearchX->dy < Pattern->dy. |
ERR_FORMAT | if SearchX->dx * SearchX->dy >= 4096 * 4096. |
ERR_MEMORY | if Memory Allocation Fails. |
ERR_SINGULAR | if no correlation found. |
ERR_BOUNDS | if subpixel interpolation was not possible because the pattern was found at the image border (function returns pixel precise position output). |
ERR_LOWPREC | if Subpixel Interpolation is not possible, result is pixel precise. |
ERR_NONE | on Success. |
ERR_FORMAT | if SearchX->dx or SearchX->dy, or Pattern->dx or Pattern->dy are not in Range [0,65535]. |
ERR_FORMAT | if SearchX->dx < Pattern->dx or SearchX->dy < Pattern->dy. |
ERR_FORMAT | if SearchX->dx * SearchX->dy >= 4096 * 4096. |
ERR_MEMORY | if Memory Allocation Fails. |
ERR_SINGULAR | if no correlation found. |
ERR_BOUNDS | if subpixel interpolation was not possible because the pattern was found at the image border (function returns pixel precise position output). |
ERR_LOWPREC | if Subpixel Interpolation is not possible, result is pixel precise. |
ERR_NONE | on Success. |
I32 NormalizedCorrelationI32 | ( | image * | SearchX, |
image * | Pattern, | ||
float | MinContr, | ||
I32 * | Corr, | ||
float * | Contr, | ||
I32 * | PosX, | ||
I32 * | PosY | ||
) |
This function calls the function NormalizedCorrelation(). It has been kept for compatibility reasons. In case of doubt we recommend using NormalizedCorrelation() directly.
SearchX | The Image to be Searched In. |
Pattern | The Reference Pattern. |
MinContr | The Minimum Contrast Requirement, can speed up the Search. |
Corr | Correlation Value Output, Set to NULL, if not Required. |
Contr | Contrast Value Output, Set to NULL, if not Required. |
PosX | x-Position Output, Set to NULL, if not Required. |
PosY | y-Position Output, Set to NULL, if not Required. |
I32 BarCorrV | ( | image * | SearchX, |
image * | Pattern, | ||
float | MinContr, | ||
I32 * | Corr, | ||
float * | Contr, | ||
I32 * | PosX | ||
) |
This function searches a pattern defined by image Pattern
in the SearchX
image using normalized correlation. A minimum contrast and a minimum correlation value may be specified by the variables MinContr
(set MinContr
= 0 if not needed) and MinCorr
(set MinCorr
= 0 if not needed). If the pattern is found the X- and Y-position is returned as well as the correlation value of the match and the contrast of the image at this position.
Unlike other 2D correlation functions, this function uses (moving) averages in y direction to compensate for a missing y kernel dimension, so - for this function - a kernel size of kx * ky means averaging ky lines and correlating the resulting kx pixels to a line signal. The dy-dimensions of the search and the reference images MUST BE EQUAL
This function may be used for the skew detection of a barcode.
maximum kernel size: kx * ky <= 4096 x 4096 and kx < 65536
This Correlation is done with pixel accuracy.
SearchX | The Image to be Searched In. |
Pattern | The Reference Pattern. |
MinContr | The Minimum Contrast Requirement, can speed up the Search. |
Contr | Contrast Value Output, Set to NULL, if not Required. |
Corr | Correlation Value Output, Set to NULL, if not Required. |
PosX | x-Position Output, Set to NULL, if not Required. |
I32 BarCorrV2 | ( | image * | SearchX, |
image * | Pattern, | ||
float | MinContr, | ||
I32 * | Corr, | ||
float * | Contr, | ||
I32 * | PosX, | ||
I32 * | PosY | ||
) |
This function searches a pattern defined by image Pattern
in the SearchX
image using normalized correlation. A minimum contrast and a minimum correlation value may be specified by the variables MinContr
(set MinContr
= 0 if not needed) and MinCorr
(set MinCorr
= 0 if not needed). If the pattern is found the X- and Y-position is returned as well as the correlation value of the match and the contrast of the image at this position.
Unlike other 2D correlation functions, this function uses (moving) averages in y direction to compensate for a missing y kernel dimension, so - for this function - a kernel size of kx * ky means averaging ky lines and correlating the resulting kx pixels to a line signal. line signal. Unlike BarCorrV(), this function is able to search the pattern in a larger image with SearchX->dy > Pattern->dy providing a position in y-direction for the best match. For SearchX->dy = Pattern->dy the function may be used but function BarCorrV() is considerably faster.
This function may be used for the left and right registration of a barcode.
maximum kernel size: kx * ky <= 4096 x 4096 and kx < 65536
This Correlation is done with pixel accuracy.
SearchX | The Image to be Searched In. |
Pattern | The Reference Pattern. |
MinContr | The Minimum Contrast Requirement, can speed up the Search. |
Contr | Contrast Value Output, Set to NULL, if not Required. |
Corr | Correlation Value Output, Set to NULL, if not Required. |
PosX | x-Position Output, Set to NULL, if not Required. |
PosY | y-Position Output, Set to NULL, if not Required. |