Thread Subject: Need explaination on the coding!

Subject: Need explaination on the coding!

From: wilson

Date: 31 Oct, 2009 13:13:02

Message: 1 of 6

Can anyone explain for me how can this coding work? I get this from the file exchange i just wanna to know can anyone explain for me? After i go through i still don't understand the mean n corrolate part!
% read both images sizes
[r1,c1]=size(Target);
[r2,c2]=size(Template);

% mean of the template
image22=Template-mean(mean(Template));

%corrolate both images
corrMat=[];
for i=1:(r1-r2+1)
    for j=1:(c1-c2+1)
       Nimage=Target(i:i+r2-1,j:j+c2-1);
       Nimage=Nimage-mean(mean(Nimage));
       corr=sum(sum(Nimage.*image22));
       corrMat(i,j)=corr;
    end
end

Thanks & Cheers!

Subject: Need explaination on the coding!

From: Matt Fig

Date: 31 Oct, 2009 15:29:02

Message: 2 of 6

Since you got it from the FEX, why not ask the author?

Subject: Need explaination on the coding!

From: HongXiang

Date: 31 Oct, 2009 16:20:03

Message: 3 of 6

To eliminate the mean part is equal to remove the DC component of the image.

Subject: Need explaination on the coding!

From: wilson

Date: 1 Nov, 2009 03:36:01

Message: 4 of 6

"HongXiang " <hongxiang.w@gmail.com> wrote in message <hcho3j$gcs$1@fred.mathworks.com>...
> To eliminate the mean part is equal to remove the DC component of the image.

What do u mean by remove the dc component of the image?
Sorry i kinda not understand can u explain to me more clearly?
Sorry i am a new learner in Matlab!

Subject: Need explaination on the coding!

From: ImageAnalyst

Date: 1 Nov, 2009 13:25:17

Message: 5 of 6

wilson :
From what I can tell, they are doing a cross correlation of the two
images where Target is much bigger than Template. It also appears
that they are expecting some spurious fluctuation in the illumination
of the Target image (say the scene is shadowed by a variable cloud
pattern. So to compensate for that they are subtracting the mean of
the moving window. This is done inside the loop so that it will adapt
for different means in different areas of the image. The template is
a "perfect" image or so small that there are not expected to be any
illumination fluctuations over it. But because they subtracted the
mean (which is the "DC" component) from the Target, they also did it
with the Template just to be consistent.

You should put a comment in the comment section of that submission
saying that they need to improve it by giving a good overall
description of what the thing does plus give better line-by-line
comments, and more descriptive variable names (image22 and Nimage -
those are pathetic).

And, like Matt Fig says, asking the author should always be the first
thing you should try. They know their code better than anyone here.

Subject: Need explaination on the coding!

From: wilson

Date: 1 Nov, 2009 16:19:01

Message: 6 of 6

Oh okie i understand the meaning now!
You help me alots on my task ImageAnalyst!
Thanks Cheers!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
template matching wilson 31 Oct, 2009 09:14:04
rssFeed for this Thread

Contact us at files@mathworks.com