templatematchcv
Finds a template within an image and returns the handle to an output image highlighting the match and the position of the match.
Syntax
[R, pos] = templatematchcv(src, tpl, method, color)
[R, pos] = templatematchcv(src, tpl, method, color, thickness)
Inputs
- handle
- Handle of an image.
- tpl
- Handle of the template to match. The size of the template image must be lesser than src.
- method
- Method used for template matching. Valid values are:
- color
- Three-element vector of integers representing red, green, blue (RGB) colors used on R.
- thickness
- Optional parameter specifying the thickness of the rectangle drawn. Default value of thickness is 1.
Outputs
- R
- Handle of the output image showing the match.
- pos
- Two-element vector representing the x,y coordinates of the match.
Example
Show an output image with the matched template:
src = imreadcv('cv1.jpg');
tpl = cropcv(src, [100 200 300 500]);
[R, pos] = templatematchcv(src, tpl, 0, [0, 0, 135], 4);
Identify the position of the Altair logo in the Altair website snippet:
src = imreadcv('AltairWebsite.png');
tpl = imreadcv('AltairLogo.png');
[R, pos] = templatematchcv(src, tpl, 0, [0, 0, 135], 4);
imshowcv(R);