M-File Help: imatch | View code for imatch |
Template matching
xm = imatch(im1, im2, u, v, H, s) is the position of the matching subimage of im1 (template) within the image im2. The template in im1 is centred at (u,v) and its half-width is H.
The template is searched for within im2 inside a rectangular region, centred at (u,v) and whose size is a function of s. If s is a scalar the search region is [-s, s, -s, s] relative to (u,v). More generally s is a 4-vector s=[umin, umax, vmin, vmax] relative to (u,v).
The return value is xm=[DU,DV,CC] where (DU,DV) are the u- and v-offsets relative to (u,v) and CC is the similarity score for the best match in the search region.
[xm,score] = imatch(im1, im2, u, v, H, s) as above but also returns a matrix of matching score values for each template position tested. The rows correspond to horizontal positions of the template, and columns the vertical position. The centre element corresponds to (u,v).
Consider a sequence of images im(:,:,N) and we find corner points in the k'th image
corners = icorner(im(:,:,k), 'nfeat', 20);
Now, for each corner we look for the 11x11 patch of surrounding pixels in the next image, by searching within a 21x21 region
for corner=corners
xm = imatch(im(:,:,k), im(:,:,k+1), 5, 10); if xm(3) > 0.8
fprintf('feature (%f,%f) moved by (%f,%f) pixels)\n', ...
corner.u, corner.v, xm(1), xm(2) );
end
end
© 1990-2012 Peter Corke.