Re: Matching method
- From: "Don " <dany.1986@xxxxxxxxxxxxx>
- Date: Thu, 11 Mar 2010 01:46:04 +0000 (UTC)
ImageAnalyst <imageanalyst@xxxxxxxxxxxxxx> wrote in message <e8774cea-209f-4bdd-8a81-96b29856953b@xxxxxxxxxxxxxxxxxxxxxxxxxxx>...
On Feb 22, 10:34 pm, "Marcus " <sbeng_...@xxxxxxxxx> 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.
.
- Follow-Ups:
- Re: Matching method
- From: Bruno Luong
- Re: Matching method
- From: ImageAnalyst
- Re: Matching method
- Prev by Date: Re: Linear correlation
- Next by Date: Re: making local variable global
- Previous by thread: setting figure size limits
- Next by thread: Re: Matching method
- Index(es):
Relevant Pages
|