Моя главная цель — показать, что теорема о свёртке работает (напомню: теорема о свёртке означает, что idft(dft(im) .* dft(mask)) = conv(im, mask)
). Я пытаюсь это запрограммировать.
Вот мой код:
function displayTransform( im )
% This routine displays the Fourier spectrum of an image.
%
% Input: im - a grayscale image (values in [0,255])
%
% Method: Computes the Fourier transform of im and displays its spectrum,
% (if F(u,v) = a+ib, displays sqrt(a^2+b^2)).
% Uses display techniques for visualization: log, and stretch values to full range,
% cyclic shift DC to center (use fftshift).
% Use showImage to display and fft2 to apply transform.
%displays the image in grayscale in the Frequency domain
imfft = fft2(im);
imagesc(log(abs(fftshift(imfft))+1)), colormap(gray);
% building mask and padding it with Zeros in order to create same size mask
b = 1/16*[1 1 1 1;1 1 1 1; 1 1 1 1; 1 1 1 1];
paddedB = padarray(b, [floor(size(im,1)/2)-2 floor(size(im,2)/2)-2]);
paddedB = fft2(paddedB);
C = imfft.*paddedB;
resIFFT = ifft2(C);
%reguler convolution
resConv = conv2(im,b);
showImage(resConv);
end
Я хочу сравнить resIFFT
и resConv
. Я думаю, что мне не хватает приведения, потому что я получаю числа в матрице ближе друг к другу, если я использую приведение к двойному. Может у меня какая-то ошибка в месте литья или прокладки?
im
иb
в двойные. - person Shai   schedule 25.12.2012