A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
matchTemplate
ArrayFire Functions | ArrayFire Functions by Category » Computer Vision » Template matching

Template Matching More...

## Functions
AFAPI array | matchTemplate (const array &searchImg, const array &templateImg, const matchType mType=AF_SAD)
| C++ Interface for image template matching.
AFAPI af_err | af_match_template (af_array *out, const af_array search_img, const af_array template_img, const af_match_type m_type)
| C Interface for image template matching.

## Detailed Description

Template Matching

Template Matching

Template matching is an image processing technique to find small patches of an image which match a given template image. A more in depth discussion on the topic can be found here.

Template matching is an image processing technique to find small patches of an image which match a given template image. Currently, this function doesn't support the following three metrics yet.

- AF_NCC
- AF_ZNCC
- AF_SHD

A more in depth discussion about template matching can be found here.

## Function Documentation

## ◆ af_match_template()

AFAPI af_err af_match_template | ( | af_array * | out,
|  | const af_array | search_img,
|  | const af_array | template_img,
|  | const af_match_type | m_type )

C Interface for image template matching.

Parameters

  [out] | out | will have disparity values for the window starting at corresponding pixel position
  [in] | search_img | is an array with image data
  [in] | template_img | is the template we are looking for in the image
  [in] | m_type | is metric that should be used to calculate the disparity between window in the image and the template image. It can be one of the values defined by the enum af_match_type

Returns
  AF_SUCCESS if disparity metric is computed successfully, otherwise an appropriate error code is returned.

Note
  If `search_img` is 3d array, a batch operation will be performed.

## ◆ matchTemplate()

AFAPI array matchTemplate | ( | const array & | searchImg,
|  | const array & | templateImg,
|  | const matchType | mType = AF_SAD )

C++ Interface for image template matching.

Parameters

  [in] | searchImg | is an array with image data
  [in] | templateImg | is the template we are looking for in the image
  [in] | mType | is metric that should be used to calculate the disparity between window in the image and the template image. It can be one of the values defined by the enum af_match_type

Returns
  array with disparity values for the window starting at corresponding pixel position

Note
  If `search_img` is 3d array, a batch operation will be performed.