Matlab 中基于傅立叶的字符识别

发布于 2024-10-20 04:18:11 字数 390 浏览 4 评论 0原文

我有一个可以识别图像中字符位置的源代码。但有一行代码我不明白为什么?

[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

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
        if splash(i,j)>=thresh 
            splash(i,j)=1;
        else
           splash(i,j)=0;
        end
    end
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花想c 2024-10-27 04:18:11

我的 FFT 知识有点生疏,但我认为这本质上是计算互相关

频域中的乘法相当于空间/时间域中的卷积。互相关相当于与反转信号进行卷积——这就是 180° 旋转试图做的事情。在我有点醉的头脑中,我无法判断这个特定的实现是否应该起作用。

Matlab 具有直接计算互相关的函数,但它们可能位于此代码的作者(或预期用户)无法使用的工具箱中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文