开发者

Fourier Based Character Recognition in Matlab

开发者 https://www.devze.com 2023-02-14 23:10 出处:网络
I have a source code that could recognize a character\'s position in an image. but there is a line of code that i can\'t figure it out WHY?

I have a source code that could recognize a character's position in an image. but there is a line of code that i can't figure it out WHY?

[r c]=size(mainImage);

% Why rotate 90 degree? why multyply? why??? :-??
splash = real(ifft2(fft2(mainImage) .* fft2(rot90(object, 2), r, c)));

thresh = max(splash(:))-10;
for i=1:r
    for j=1:c
  开发者_如何学JAVA      if splash(i,j)>=thresh 
            splash(i,j)=1;
        else
           splash(i,j)=0;
        end
    end
end


My FFT knowledge is a bit rusty, but I think this is essentially calculating the cross-correlation.

Multiplication in the frequency domain is equivalent to convolution in the space/time domain. And cross-correlation is equivalent to convolution with the inverted signal -- which is what the 180° rotation is trying to do. Off the top of my slightly-drunk head I can't say whether this specific implementation should be expected to work.

Matlab has functions to calculate cross-correlations directly, but they may reside in toolboxes that weren't available to the author (or expected users) of this code.

0

精彩评论

暂无评论...
验证码 换一张
取 消