Search This Blog

Pattern Finding in Images using Cross Correlation

clc

clear all

close all

a=imread('Capture1.JPG');

at=rgb2gray(a);

figure;

imshow(a);

title('Original Image');

bt=imread('Capture2.JPG');

b=rgb2gray(bt);

figure;

imshow(bt);

title('Pattern');

cross=normxcorr2(b,at);

[y x]=find(cross>=0.98*max(cross(:)));

ynew=y-size(b,1);

xnew=x-size(b,2);

figure;

imshow(a);

for i=1:length(xnew)

imrect(gca,[xnew(i)+1,ynew(i)+1,size(b,2),size(b,1)]);

hold on;

end

title('Found Patterns');




No comments