On Nov 9, 4:25 am, "Prasanna " <pmgunaward...@gmail.com> wrote:
> Hi all,
> I am having a binary image "I" which is 480*640 size.
> And my templates are "temp1"(size 146*149 binary) and temp2 (size 96*96 binary).
>
> Now I want to match these 2 templates with image "I" and identify the matching locations in the image "I".
>
> Please some one send me the MATLAB code for this. Because I'm not familiar with the this section.
-------------------------------------------------------------------------------------------------------
I'm not sure how long it will take, but if your templates are in the
image (i.e. the version of the template in the image is not scaled or
rotated) you can use the xcorr2() function in the Signal Processing
Toolbox to do a cross correlation of the images. This is a simple one-
liner solution - actually a little more because you'd have to search
the resulting array for the max using the find() function or similar
alternate ways. If you don't have that toolbox, you can easily write
it yourself in a few lines (4 nested for loops in the spatial domain).
Thanks 4 replying. Below display the template matching code that I wrote. I did this using several demos those are in the MATLAB 2008a version. Here "someblobsI" means the binary image. "Icropped" means the template(which is also binary). no rotations and scalings happenning to both image and the template. Is this code relevant to my application or should I change something here?
C = real(ifft2(fft2(someblobsI) .* fft2(rot90(Icropped,2),480,640)));
figure, imshow(C,[]);
max(C(:))
thresh = 1000 ; % Use a threshold that's a little less than max.
figure, imshow(C > thresh); % identification
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.