The OpenVX Specification  dba1aa3
MatchTemplate

Detailed Description

Compares an image template against overlapped image regions.

The detailed equation to the matching can be found in vx_comp_metric_e. The output of the template matching node is a comparison map. The output comparison map should be the same size as the input image. The template image size (width*height) shall not be larger than 65535. If the valid region of the template image is smaller than the entire template image, the result in the destination image is implementation-dependent.

Enumerations

enum  vx_comp_metric_e {
  VX_COMPARE_HAMMING = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_COMP_METRIC << 12)) + 0x0,
  VX_COMPARE_L1 = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_COMP_METRIC << 12)) + 0x1,
  VX_COMPARE_L2 = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_COMP_METRIC << 12)) + 0x2,
  VX_COMPARE_CCORR = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_COMP_METRIC << 12)) + 0x3,
  VX_COMPARE_L2_NORM = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_COMP_METRIC << 12)) + 0x4,
  VX_COMPARE_CCORR_NORM = ((( VX_ID_KHRONOS ) << 20) | ( VX_ENUM_COMP_METRIC << 12)) + 0x5
}
 comparing metrics. More...
 

Functions

vx_node VX_API_CALL vxMatchTemplateNode (vx_graph graph, vx_image src, vx_image templateImage, vx_enum matchingMethod, vx_image output)
 [Graph] The Node Compares an image template against overlapped image regions. More...
 
vx_status VX_API_CALL vxuMatchTemplate (vx_context context, vx_image src, vx_image templateImage, vx_enum matchingMethod, vx_image output)
 [Immediate] The function compares an image template against overlapped image regions. More...
 

Enumeration Type Documentation

comparing metrics.

In all the equations below w and h are width and height of the template image respectively. \( R \) is the compare map. \( T \) is the template image. \( I \) is the image on which the template is searched.

Enumerator
VX_COMPARE_HAMMING 

hamming distance \( R(x,y) = \frac{1}{w*h}\sum_{\grave{x},\grave{y}}^{w,h} XOR(T(\grave{x},\grave{y}),I(x+\grave{x},y+\grave{y}))\)

VX_COMPARE_L1 

L1 distance \( R(x,y) = \frac{1}{w*h}\sum_{\grave{x},\grave{y}}^{w,h} ABS(T(\grave{x},\grave{y}) - I(x+\grave{x},y+\grave{y}))\).

VX_COMPARE_L2 

L2 distance normalized by image size \( R(x,y) = \frac{1}{w*h}\sum_{\grave{x},\grave{y}}^{w,h} (T(\grave{x},\grave{y}) - I(x+\grave{x},y+\grave{y}))^2\).

VX_COMPARE_CCORR 

cross correlation distance \( R(x,y) = \frac{1}{w*h}\sum_{\grave{x},\grave{y}}^{w,h} (T(\grave{x},\grave{y})*I(x+\grave{x},y+\grave{y}))\)

VX_COMPARE_L2_NORM 

L2 normalized distance \( R(x,y) = \frac{\sum_{\grave{x},\grave{y}}^{w,h} (T(\grave{x},\grave{y}) - I(x+\grave{x},y+\grave{y}))^2} {\sqrt{\sum_{\grave{x},\grave{y}}^{w,h} T(\grave{x},\grave{y})^2 * I(x+\grave{x},y+\grave{y})^2}} \).

VX_COMPARE_CCORR_NORM 

cross correlation normalized distance \( R(x,y) = \frac{\sum_{\grave{x},\grave{y}}^{w,h} T(\grave{x},\grave{y}) * I(x+\grave{x},y+\grave{y})*2^{15}} {\sqrt{\sum_{\grave{x},\grave{y}}^{w,h} T(\grave{x},\grave{y})^2 * I(x+\grave{x},y+\grave{y})^2}} \)

Definition at line 1447 of file vx_types.h.

Function Documentation

vx_node VX_API_CALL vxMatchTemplateNode ( vx_graph  graph,
vx_image  src,
vx_image  templateImage,
vx_enum  matchingMethod,
vx_image  output 
)

[Graph] The Node Compares an image template against overlapped image regions.

The detailed equation to the matching can be found in vx_comp_metric_e. The output of the template matching node is a comparison map as described in vx_comp_metric_e. The Node have a limitation on the template image size (width*height). It should not be larger then 65535. If the valid region of the template image is smaller than the entire template image, the result in the destination image is implementation-dependent.

Parameters
[in]graphThe reference to the graph.
[in]srcThe input image of type VX_DF_IMAGE_U8.
[in]templateImageSearched template of type VX_DF_IMAGE_U8.
[in]matchingMethodattribute specifying the comparison method vx_comp_metric_e. This function support only VX_COMPARE_CCORR_NORM and VX_COMPARE_L2.
[out]outputMap of comparison results. The output is an image of type VX_DF_IMAGE_S16
Returns
vx_node.
Return values
vx_nodeA node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus
vx_status VX_API_CALL vxuMatchTemplate ( vx_context  context,
vx_image  src,
vx_image  templateImage,
vx_enum  matchingMethod,
vx_image  output 
)

[Immediate] The function compares an image template against overlapped image regions.

The detailed equation to the matching can be found in vx_comp_metric_e. The output of the template matching node is a comparison map as described in vx_comp_metric_e. The Node have a limitation on the template image size (width*height). It should not be larger then 65535. If the valid region of the template image is smaller than the entire template image, the result in the destination image is implementation-dependent.

Parameters
[in]contextThe reference to the overall context.
[in]srcThe input image of type VX_DF_IMAGE_U8.
[in]templateImageSearched template of type VX_DF_IMAGE_U8.
[in]matchingMethodattribute specifying the comparison method vx_comp_metric_e. This function support only VX_COMPARE_CCORR_NORM and VX_COMPARE_L2.
[out]outputMap of comparison results. The output is an image of type VX_DF_IMAGE_S16
Returns
A vx_status_e enumeration.
Return values
VX_SUCCESSSuccess
*An error occurred. See vx_status_e.