Fourier-based character recognition in Matlab

I have source code that can recognize the position of a character in an image. but there is a line of code that I cannot understand, 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
        if splash(i,j)>=thresh 
            splash(i,j)=1;
        else
           splash(i,j)=0;
        end
    end
end
+3
source share
1 answer

My FFT knowledge is a little rusty, but I think it essentially computes cross-correlation .

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

Matlab - , , ( ) .

+5

Source: https://habr.com/ru/post/1795882/


All Articles