Products & Services Solutions Academia Support User Community Company

Learn more about Video and Image Processing Blockset   

Template Matching - Locate a template in an image

Library

Analysis & Enhancement

Description

The Template Matching block finds the best match of a template within an input image. The block computes match metric values by shifting a template over a region of interest or the entire image, and then finds the best match location.

Algorithm

The match metrics use a difference equation with general form:

denotes the metric space for n > 1.

Main Dialog Box

The Main pane of the Template Matching block appears as shown in the following figure.

Match metric

Select one of three types of match metrics:

Output

Select one of two output types:

Search method

This option appears when you select Best match location for the Output parameter. Select one of two search methods.

Output NxN matrix of metric values around best match

This option appears when you select Best match location for the Output parameter. Select the check box to output a matrix of metric values centered around the best match. When you do so, the block adds the NMetric and NValid output ports.

N

This option appears when you select the Output NxN matrix of metric values around best match check box. Enter an integer number that determines the size of the N-by-N output matrix centered around the best match location index. N must be an odd number.

Enable ROI processing

This option appears when you select Best match location for the Output parameter. Select the check box for the Template Matching block to perform region of interest processing. When you do so, the block adds the ROI input port and the Output flag indicating if ROI is valid check box appears.

Output flag indicating if ROI is valid

This option appears when you select the Enable ROI processing check box. Select the check box for the Template Matching block to indicate whether the ROI is within the valid region of the image boundary. When you do so, the block adds the ROIValid output port.

Fixed-point Dialog Box

The Fixed-point pane of the Template Matching block dialog box appears as shown in the following figure.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Accumulator

Use this parameter to specify how you would like to designate the accumulator word and fraction lengths.

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent the autoscaling tool in the Fixed-Point Tool overriding any fixed-point scaling you specify in this block mask. For more information, see fxptdlg, a reference page on the Fixed-Point Tool in the Simulink documentation.

Supported Data Types

PortSupported Data Types
I (Input Image)
  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed, unsigned or both)

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

T (Template)
  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed, unsigned or both)

  • Boolean

  • 8-bit unsigned integers

ROI (Region of Interest)
  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed, unsigned or both)

  • Boolean

  • 8-bit unsigned integers

Metric (Match Metric Values)
  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed, unsigned or both)

  • Boolean

  • 32-bit unsigned integers

Loc (Best match location [x,y])
  • 32-bit unsigned integers

NMetric (Metric values in Neighborhood of best match)
  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed, unsigned or both)

  • Boolean

  • 8-bit unsigned integers

NValid (Neighborhood valid)
  • Boolean

ROIValid (ROI valid)
  • Boolean

Reference

[1] Koga T., et. Al. Motion-compensated interframe coding for video conferencing. In National Telecommunications Conference. Nov. 1981, G5.3.1–5, New Orleans, LA.

[2] Zakai M., "General distance criteria" IEEE Transaction on Information Theory, pp. 94–95, January 1964.

[3] Yu, J., J. Amores, N. Sebe, Q. Tian, "A New Study on Distance Metrics as Similarity Measurement" IEEE International Conference on Multimedia and Expo, 2006 .

See Also

Template Matching

Video Stabilization Demo

Video and Image Processing Blockset Demos

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS