Finding correlation between two images

Can someone tell me why this program is not working..
Searching for an object in a bitmap image. The program runs without error, however, the x-mark and line plots are in completely random places on the image and not where the most correlation should be. Also, the x-mark is in a different location to the two maxRow and maxCol plots?
Cheers.
clear all; close all; clc; G1 = imread('searchSpace.bmp'); G1 = squeeze(G1(:,:,1)); G2 = imread('searchObject.bmp'); G2 = squeeze(G2(:,:,1)); G4 = G2;
M = size(G1,1); N = size(G1,2);
scaleFactor = 0.25;
while scaleFactor <= 4
maxCorr=0;maxRow=0;maxCol=0;
for rotateFactor = 0:90:360
G2 = imresize(G4, scaleFactor);
G2 = imrotate(G2, rotateFactor);
G3 = zeros(M,N);
maskW = size(G2,1);
for row=floor(maskW/2)+1:M-floor(maskW/2)
for col=floor(maskW/2)+1:N-floor(maskW/2)
G3(row,col) = corr2(G1(row-floor(maskW/2):row+floor(maskW/2), ...
col-floor(maskW/2):col+floor(maskW/2)),G2);
end
end
for row=1:size(G3,1)
for col=1:size(G3,2)
if(G3(row,col)>maxCorr)
maxCorr = G3(row,col);
maxRow = row;
maxCol = col;
end
end
end
end
scaleFactor = scaleFactor + 1;
end
imshow(G1);
hold on;
plot(maxRow, maxCol, 'cx');
hold on;
plot([0 size(G1,1)], [maxRow maxRow], 'c-');
plot([maxCol maxCol], [0 size(G1,2)], 'c-');

댓글 수: 1

Image Analyst
Image Analyst 2014년 12월 20일
I answered your last question (thanks for accepting it) but you edited it away - those kinds of behaviors don't really entice people to answer you anymore.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Interactions, Camera Views, and Lighting에 대해 자세히 알아보기

태그

질문:

2014년 12월 17일

댓글:

2014년 12월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by