理想低通滤波器 MatLab实现源码
%%
M = 128;
N = 128;
u = 0 : M-1;
v = 0 : N-1;
u = u - M/2;
v = v - N/2;
[V,U]=meshgrid(v,u);
D0 = 15;
Hd = zeros(length(u),length(v));
d = round(sqrt(U.^2 + V.^2)) <= D0;
Hd(d) = 1;
mesh(U,V,Hd)
axis tight
% grid off
set(gca, 'XTickLabel',{'','','',0,'','',''},'YTickLabel',{'','','',0,'','',''},'ZTickLabel',{0,'','','','',1})
xlabel('u','FontName','Times New Roman','FontAngle','Italic','FontSize',12,'VerticalAlignment','bottom')
ylabel('v','FontName','Times New Roman','FontAngle','Italic','FontSize',12,'VerticalAlignment','bottom')
zlabel('H(u,v)','FontName','Times New Roman','FontAngle','Italic','FontSize',12)
print('-djpeg', 'ILPF.jpg')
imwrite(mat2gray(Hd),'ILPF_IMG.bmp')
figure;plot(v, Hd(M/2+1,:),'LineWidth',1.5)
xlabel('D(u,v)','FontName','Times New Roman','FontAngle','Italic','FontSize',12)
ylabel('H(u,v)','FontName','Times New Roman','FontAngle','Italic','FontSize',12)
axis([0 max(v) 0 1.1])
set(gca, 'XTickLabel',[],'YTickLabel',[])
text(D0, 0,'D_{0}','VerticalAlignment','top','FontAngle','Italic')
text(0, 1,'1','HorizontalAlignment','right')
print('-djpeg', 'ILPF_Profile.jpg')