From: Marcus on
If i wan to use correlation to do some matching on 2 images?
How should i write it?
i use the for loop to write it then
write the percentage equation to show that how much many percentage similar is this 2 image! But error!

Can anybody show me some example to match 2 images?
From: ImageAnalyst on
How about using xcorr2() to do correlation?
From: Marcus on

Sir can you show me some example how to do matching by using correlation?
like simply take 2 pic and do some matching then at the end show how many percent the image is similar!
From: ImageAnalyst on
On Feb 22, 10:34 pm, "Marcus " <sbeng_...(a)yahoo.com> wrote:
> Sir can you show me some example how to do matching by using correlation?
> like simply take 2 pic and do some matching then at the end show how many percent the image is similar!
------------------------------------------------------------------------------------------------------------------------------------------------------
I had a suspicion you'd ask that because even though the syntax is
actually very very simple (c = xcorr(image1, image2)), they don't give
an actual example with actual code in the "Examples" section. So it's
below. To answer your question, you'd have to define how you define
"percent." It's not so simple and you could think of lots of
definitions. Also define "matching" which is also very ambigous with
lots of possible definitions - what's yours?

% function cross_correlation_demo()
% Demo to do a cross correlation.
% by ImageAnalyst
clc;
close all;
clear all;
% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
fontSize = 20;

% Read in standard MATLAB demo image.
grayImage = imread('cameraman.tif');
subplot(2,2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

% Get a small sub-image around the cameraman's head
row1 = 37;
row2 = 80;
col1 = 96;
col2 = 134;
subImage = grayImage(row1:row2, col1:col2);
subplot(2,2, 2);
imshow(subImage, []);
title('Sub Image', 'FontSize', fontSize);
normalizingFactor =
sqrt(sum(dot(grayImage,grayImage))*sum(dot(subImage,subImage)))

crossCorrelationImage = xcorr2(grayImage, subImage);
normalizedCrossCorrelationImage = single(crossCorrelationImage) /
normalizingFactor;
subplot(2,2, 3);
imshow(normalizedCrossCorrelationImage, []);
title('Cross correlation Image', 'FontSize', fontSize);

From: Don on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <e8774cea-209f-4bdd-8a81-96b29856953b(a)t1g2000vbq.googlegroups.com>...
> On Feb 22, 10:34 pm, "Marcus " <sbeng_...(a)yahoo.com> wrote:
> > Sir can you show me some example how to do matching by using correlation?
> > like simply take 2 pic and do some matching then at the end show how many percent the image is similar!
> ------------------------------------------------------------------------------------------------------------------------------------------------------
> I had a suspicion you'd ask that because even though the syntax is
> actually very very simple (c = xcorr(image1, image2)), they don't give
> an actual example with actual code in the "Examples" section. So it's
> below. To answer your question, you'd have to define how you define
> "percent." It's not so simple and you could think of lots of
> definitions. Also define "matching" which is also very ambigous with
> lots of possible definitions - what's yours?
>
> % function cross_correlation_demo()
> % Demo to do a cross correlation.
> % by ImageAnalyst
> clc;
> close all;
> clear all;
> % Change the current folder to the folder of this m-file.
> % (The line of code below is from Brett Shoelson of The Mathworks.)
> if(~isdeployed)
> cd(fileparts(which(mfilename)));
> end
> fontSize = 20;
>
> % Read in standard MATLAB demo image.
> grayImage = imread('cameraman.tif');
> subplot(2,2, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
>
> % Get a small sub-image around the cameraman's head
> row1 = 37;
> row2 = 80;
> col1 = 96;
> col2 = 134;
> subImage = grayImage(row1:row2, col1:col2);
> subplot(2,2, 2);
> imshow(subImage, []);
> title('Sub Image', 'FontSize', fontSize);
> normalizingFactor =
> sqrt(sum(dot(grayImage,grayImage))*sum(dot(subImage,subImage)))
>
> crossCorrelationImage = xcorr2(grayImage, subImage);
> normalizedCrossCorrelationImage = single(crossCorrelationImage) /
> normalizingFactor;
> subplot(2,2, 3);
> imshow(normalizedCrossCorrelationImage, []);
> title('Cross correlation Image', 'FontSize', fontSize);


Hello

How can I use your code above to match two images? Your code gives correlated image of the original one. In my understanding it doesn't perform matching function...or am I wrong? What should be the code to tell that sub image(in this case head) belong to the original image ie. matching takes place ? Can you give a hint how to do it? Please.