clear;
I=imread('1.jpg');
I=rgb2gray(I);
figure; subplot(2,3,1);imshow(I);title('原图像');
[m,n]=size(I);
F=fftshift(fft2(I));
k=0.0025;
for u=1:m %退化模型
for v=1:n
H(u,v)=exp((-k)*(((u-m/2)^2+(v-n/2)^2)^(5/6)));
end
end
G0=F.*H;
I0=real(ifft2(fftshift(G0)));
noise=imnoise(zeros(size(I0)),'gaussian',0,0.001) ;
I1=I0+noise;
subplot(2,3,3);imshow(uint8(I1));title('模糊退化且添加高斯噪声的图像');
%逆滤波复原
G=fftshift(fft2(I1)); %傅里叶变换
F1=G./H;
I2=ifft2(fftshift(F1));
subplot(2,3,4);imshow(uint8(I2));title('逆滤波复原图');
%维纳滤波复原
K=0.1;
for u=1:m
for v=1:n
H(u,v)=exp(-k*(((u-m/2)^2+(v-n/2)^2)^(5/6)));
H0(u,v)=(abs(H(u,v)))^2;
H1(u,v)=H0(u,v)/(H(u,v)*(H0(u,v)+K));
end
end
F2=H1.*G;
I3=ifft2(fftshift(F2));
subplot(2,3,5);imshow(uint8(I3));title('维纳滤波复原图');
%最小二乘方滤波
X=[0,-1,0;-1,4,-1;0,-1,0];
L=zeros(m,n);
for i=1:3
for j=1:3
L(i,j)=X(i,j);
end
end
for u=1:m
for v=1:n
P(u,v)=fftshift(fft2(L(u,v)));%拉布拉斯算子的傅里叶变化
end
end
s=0.1;
for u=1:m
for v=1:n
H(u,v)=exp(-k*(((u-m/2)^2+(v-n/2)^2)^(5/6)));
H0(u,v)=(abs(H(u,v)))^2;
P0(u,v)=(abs(P(u,v)))^2;
H2(u,v)=conj(H(u,v));%共轭
H1(u,v)=H2(u,v)/(H0(u,v)+P0(u,v)*s);
end
end
F3=H1.*G;
I4=ifft2(fftshift(F3));
subplot(236);imshow(uint8(I4));title('最小二乘方滤波复原图');
- 1
- 2
前往页