best_match ( Image : : TemplateID, MaxError, SubPixel : Row, Column, Error )

Searching the best matching of a template and an image.

The operator best_match performs a matching of the template of TemplateID and Image. Hereby the template will be moved over the points of Image so that the template will lie always inside Image. best_match works similar to fast_match, with the exception, that each time a better match is found the value of MaxError is internally updated to a lower value to reduce runtime.

With regard to the parameter SubPixel, the position will be indicated by subpixel accuracy. The matching criterion (``displaced frame difference'') is defined as follows:


                   SUMu,v {ABS { Image[row-u,col-v] - Template[u,v] }}     
error[row,col] =  -----------------------------------------------------,
                                    AREA ( Template )                     
The runtime of the operator depends on the size of the domain of Image. Therefore it is important to restrict the domain as far as possible, i.e. to apply the operator only in a very confined ``region of interest''. The parameter MaxError determines the maximal error which the searched position is allowed to have at most. The lower this value is, the faster the operator runs.

Row and Column return the position of the best match, whereby Error indicates the average difference of the grayvalues. If no position with an error below MaxError was found the position (0,0) and a matching result of 255 for Error are returned. In this case MaxError has to be set larger.

The maximum error of the position (without noise) is 0.1 pixel. The average error is 0.03 pixel.


Parameters

Image (input_object)
image(-array) -> object : byte
Input image inside of which the pattern has to be found.

TemplateID (input_control)
template -> integer
Template number.

MaxError (input_control)
real -> real
Maximum average difference of the grayvalues.
Default value: 20
Suggested values: 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 60, 70
Typical range of values: 0 <= MaxError <= 255
Minimum increment: 1
Recommended increment: 3

SubPixel (input_control)
string -> string
Subpixel accuracy in case of 'true'.
Default value: 'false'
List of values: 'true', 'false'

Row (output_control)
point.y(-array) -> real
Row position of the best match.

Column (output_control)
point.x(-array) -> real
Column position of the best match.

Error (output_control)
real(-array) -> real
Average divergence of the grayvalues of the best match.


Result

If the parameter values are correct, the operator best_match returns the value 2 (H_MSG_TRUE). If the input is empty (no input images are available) the behaviour can be set via set_system('no_object_result',<Result>). If necessary, an exception handling is raised.


Parallelization Information

best_match is reentrant and automatically parallelized (on tuple level).


Possible Predecessors

create_template, read_template, set_offset_template, set_reference_template, adapt_template, draw_region, draw_rectangle1, reduce_domain


Alternatives

fast_match, fast_match_mg, best_match_mg, best_match_pre_mg, best_match_rot, best_match_rot_mg, exhaustive_match, exhaustive_match_mg


Module

Matching



Copyright © 1996-2008 MVTec Software GmbH