为什么特定的图像大小在MATLAB中需要更多的执行时间?

时间:2013-12-16 08:31:52

标签: matlab graph

我正在测试MATLAB中低通巴特沃斯图像处理滤波器的执行时间。在从64x64开始为每个维度增加64的不同图像大小运行我的代码时,我发现特定图像尺寸1984x1984比其他尺寸(如1920x1920和2048x2048尺寸图像及其后)明显花费更多时间。下图显示了平均执行时间(10次迭代)与图像尺寸的关系图。

enter image description here

图表看似异常行为的任何推理?以下是我的代码。谢谢。

f=imread('1984x1984_2.pgm');
[M,N]=size(f);
tic
%FFT of the image after padding values of the same size as image
F=single(fft2(f,2*M,2*N));
%FFT shift
Fc=single(fftshift(F));
%deleting large matrix to release memory
delete F 
%initializing the filter of the same size as the padded image
H=single(zeros(2*M,2*N));
%calculating filter values
for u=1:2*M;
for v=1:2*N;
radius = ((u-(M+1))^2 + (v-(N+1))^2)^.5; 
H(u,v)= 1./(1.0 +  (radius./ 40).^(2*2));
end;
end;
filter=H;
%multiply the filter with image spectrum
G=H.*Fc;
%deleting large matrix to release memory
delete Fc
%Inverse FFT shift
Gsh=single(ifftshift(G));
%deleting large matrix to release memory
delete G H 
%Inverse FFT to transform the image in spatial domain
Ginv=ifft2(Gsh,2*M,2*N);
%deleting large matrix to release memory
delete Gsh
%converting to real and unpadding
Greal=single(real(Ginv(1:M,1:N)));
resultImage=Greal;
t=toc*1000

0 个答案:

没有答案