clear all;
clc;
img=imread('flower.jpg');
[R,C,N]=size(img);
newimg=zeros(R,C,N,'uint8');
for n=1:N
y=fft2(img(:,:,n));
y2=fftshift(y);
lowpass=zeros(R,C);
r_center=round(R/2);
c_center=round(C/2);
Dmax=sqrt(r_center^2+c_center^2);
cutoff=0.7;
D0=(1-cutoff)*Dmax;
w=3;
H=zeros(R,C);
for r=1:R
for c=1:C
D=sqrt((r-r_center)^2+(c-c_center)^2);
H(r,c)=1/(1+exp(-(D/D0))^(-w));
lowpass(r,c)=y2(r,c)*H(r,c);
end
end
Fn=abs(lowpass);
Fmax=max(Fn(:));
Fmin=min(Fn(:));
Fn2=(Fn-Fmin)/(Fmax-Fmin)*1024;
titl=['波段',int2str(n),'指数低通滤波傅里叶频谱'];
name=['波段',int2str(n),'指数低通滤波器'];
subplot(2,3,n),imshow(H),title(name);
subplot(2,3,n+3),imshow(Fn2),title(titl);
IFn=ifft2(lowpass);
IFn=abs(IFn);
IFn=uint8(IFn);
newimg(:,:,n)=IFn;
end
figure
imshow(newimg),title('指数低通滤波后影像')
评论0