我正在尝试使用MATLAB实现Butterworth低通滤波器。但是,即使图像尺寸仅为510x510,计算也需要很长时间。我知道问题出在嵌套的for循环内。但是,我无法修复它。你能帮我吗?预先感谢。
f=double(imread('panda.png'));
h = size(f,1);
w = size(f,2);
% Create ideal low pass filter – a circle in middle of image
R = 50; % cutoff frequency
H = zeros(h,w);
for V=1:h
for U=1:w
D = sqrt(U.^2 + V.^2);
H(V,U) = 1 / (1+ (D/R)^2) %order of the filter is 2
end
end
imshow(H, []);
H = ifftshift(H); % put zero freq in upper left corner
figure, imshow(H, []);
F = fft2(f);
G = H .* F;
g = real(ifft2(G));
figure, imshow(g, []);