matching template with image

I = imread('man.bmp'); % Load initial figure
a = imcrop(I,[50 40 150 100]);
m=imrotate(a,180);
%(Convolution is equivalent to correlation if you rotate the convolution kernel by 180.) To match the template to the image, use the fft2 and ifft2 functions.
C = real(ifft2(fft2(I).* fft2(m(a,2),256,256)));
I'm getting this error: ??? Subscript indices must either be real positive integers or logicals.
how to fix it ????

Réponses (2)

Walter Roberson
Walter Roberson le 16 Juin 2012

0 votes

You are trying to index your rotated image at your cropped image -- m(a,2)
I do not know what you intend that to mean.

5 commentaires

lama riad
lama riad le 16 Juin 2012
Locating Image Features.......http://www.mathworks.com/help/toolbox/images/f21-17064.html
actually coz my project is about image registration whatever I see related to it such as correlation I want to try it ....I have some problems in the code of registration I have I want to fix n add things; I tried n searched but no one is listening to me. I want to contact with some body to understand n encounter the problems
Walter Roberson
Walter Roberson le 16 Juin 2012
In that code, C = real(ifft2(fft2(bw) .* fft2(rot90(a,2),256,256)));
rot90 is not a variable, it is a function with parameters "a" and "2". The effect of rot90(a,2) is to rotate "a" by 180 degrees, which sounds like what you want, so it is not obvious why you did the imrotate() by 180 -- rot90 would be faster. Anyhow, change your code to
C = real(ifft2(fft2(I).* fft2(m,256,256)));
Walter Roberson
Walter Roberson le 16 Juin 2012
In the context of MATLAB Answers, "no one is listening" is usually because the regular volunteers do not happen to know anything about that field.
(I have tried answering people with "I do not know", in order to let them know that someone is listening but does not happen to have the answer, but the responses I received in return were less than appreciative.)
lama riad
lama riad le 16 Juin 2012
pardon me I mean I was seeking for help in matlab from people not necessarily in mathworks only n no one is replying I donno why I'm not professional in matlab that's why I'm asking..... some people published their works in mathwork n since I ask them regarding such a point in their work they r not replying
lama riad
lama riad le 16 Juin 2012
n thank u for the reply

Connectez-vous pour commenter.

Image Analyst
Image Analyst le 16 Juin 2012

0 votes

"a" is a matrix. So is "m" - in fact it is the rotated version of "a". So you cannot do m(a,2). The first index must be an integer number or array or a logical value or array. You cannot have a 2D or 3D matrix (an image) for an index. I haven't replied to anyone in the past 8 days because I was way out in the wilderness. I don't work for Mathworks, by the way.

Catégories

En savoir plus sur Read, Write, and Modify Image dans Centre d'aide et File Exchange

Question posée :

le 16 Juin 2012

Community Treasure Hunt

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

Start Hunting!

Translated by