poster
2019-12-14, 20:13
我有一个可以识别角色在图像中位置的源代码。但是有一行代码我无法弄清楚为什么?
[rc]=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
回答:
我的FFT知识有点生锈,但是我认为这实质上是在计算互相关 (http://en.wikipedia.org/wiki/Cross-correlation) 。
频域中的乘法等效于时空域中的卷积 (http://en.wikipedia.org/wiki/Convolution) 。互相关等效于与倒相信号的卷积-这就是180度旋转所试图做的。在我醉酒的头上,我不能说这个特定的实现是否应该起作用。
Matlab具有直接计算互相关的功能,但它们可能驻留在该代码的作者(或预期的用户)无法使用的工具箱中。
更多&回答... (https://stackoverflow.com/questions/5174224)
[rc]=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
回答:
我的FFT知识有点生锈,但是我认为这实质上是在计算互相关 (http://en.wikipedia.org/wiki/Cross-correlation) 。
频域中的乘法等效于时空域中的卷积 (http://en.wikipedia.org/wiki/Convolution) 。互相关等效于与倒相信号的卷积-这就是180度旋转所试图做的。在我醉酒的头上,我不能说这个特定的实现是否应该起作用。
Matlab具有直接计算互相关的功能,但它们可能驻留在该代码的作者(或预期的用户)无法使用的工具箱中。
更多&回答... (https://stackoverflow.com/questions/5174224)