Regarding image matching using nested loops

i have two images , say a and b ,* b* is template that is cropped from image a. using nested for loop i slided image b over a and calculating their difference and thus compairing it with a threshold, then when it matches the threshold storing its rows and columns and coordinates and making a rectangle. here is the code:
clear all; close all; clc; a=imread('abc.jpg'); b=imread('xyz.jpg'); [r c]=size(a); [i j]=size(b); for n=1:i:r-i; n=n+1 for m=1:j:c-j; m=m+1 c= imcrop(a(n ,m, i, j)); diff = abs(double(c) - double(b));
if diff>95
t=(diff);
[x y]=size(t);
xcor=n;
ycor=m;
end
end
end
imshow(a); hold; rectangle('position',[xcor ycor y x],'edgecolor','r','linewidth',4);
// the error generated is "Undefined function or variable 'xcor'.
Error in ac (line 30) rectangle('position',[xcor ycor y x],'edgecolor','r','linewidth',4); "
what should i do?? also i want to compare the threshold with the new threshold value and is this case is less than 95 it should store that value.
thanks in advance

Antworten (0)

Gefragt:

am 27 Feb. 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by