%读取原始图像
格式长
模糊= imread('fig525(B)BMP')
插曲(1,2,1) imshow(模糊)标题(原始图像)
%自我功能维纳滤波
K = 0.0025
[M,大没桥N] =尺寸(模糊)
频谱= 0(M,N)
H =零(M,N)
为u = 1:M
为V = 1: ?
H(U,V)= exp(-K *((UM / 2)^ 2 +(VN / 2)^ 2)^(5/察孙6))
光谱(U, V)= H(U,V)^ 2
结束
结束
F =双(模糊)
F1 = fftshift(FFT??2(F))
HW = H /(滚猛频谱+0.001)
restore1 = HW。 * F1
恢复=实际(ifft2(ifftshift(restore1)))
插曲(1,2,2),imshow(恢复[])标题(“自功能的维纳滤波')
%调用matlab的维纳%
数字过滤器功能
HW1 =实际(ifft2(ifftshift(H)))转化空域起来
RESULT1 = deconvwnr(模糊HW1,0.001)
结果2 = ifftshift(RESULT1)%
插曲(1逆转图片交换,1,3象限,四象限,2,1)imshow(结果2,[])标题(“呼叫维纳滤波功能')
clcclear all%读原始图像埋哗%
format long
Blurred=imread('fig525(b).bmp')
subplot(1,2,1)imshow( Blurred)title('原图像')
%自编函数进行维纳滤波%
k=0.0025
[m,n]=size(Blurred)
spectrum=zeros(m,n)
H=zeros(m,n)
for u=1:m
for v=1:n
H(u,v)=exp(-k*((u-m/2)^2+(v-n/2)^2)^(5/6))
spectrum(u,v)=H(u,v)^2
end
end
f=double(Blurred)
F1=fftshift(fft2(f))
HW=H./(spectrum+0.001)
restore1=HW.*F1
restored=real(ifft2(ifftshift(restore1)))
subplot(1,2,2)imshow(restored,[])title('自编函数进行维纳滤波')
%调用matlab提供的维纳滤波函数%
figure
hw1=real(ifft2(ifftshift(H)))%转化到空域前液隐上来
result1=deconvwnr(Blurred,hw1,0.001)
result2=ifftshift(result1)%再去图像进行1,3象限对调,2与4象限对慧厅调
subplot(1,2,1)imshow(result2,[])title('调用维纳滤波函数')
1.弊拿液维纳滤波复原I=checkerboard(8)
noise=0.1*randn(size(I))
PSF=fspecial('motion',21,11)
Blurred=imfilter(I,PSF,'circular')
BlurredNoisy=im2uint8(Blurred+noise)
NP=abs(fftn(noise)).^2
NPOW=sum(NP(:)/prod(size(noise))
NCORR=fftshift(real(ifftn(NP)))
IP=abs(fftn(I)).^2
IPOW=sum(IP(:)/prod(size(noise))
ICORR=fftshift(real(ifftn(IP)))
ICORR1=ICORR(:,ceil(size(I,1)/2))
NSR=NPOW/IPOW
subplot(221)imshow(BlurredNoisy,[])
title('模糊和噪声图像')
subplot(222)imshow(deconvwnr(BlurredNoisy,PSF,NSR),[])
title('deconbwnr(A,PSF,NSR)')
subplot(223)imshow(deconvwnr(BlurredNoisy,PSF,NCORR,ICORR),[])
title('deconbwnr(A,PSF,NCORR,ICORR)')
subplot(224)imshow(deconvwnr(BlurredNoisy,PSF,NPOW,ICORR1),[])
title('deconbwnr(A,PSF,NPOW,ICORR_1_D)')
2.规则化滤波复原程序
I=checkerboard(8)
PSF=fspecial('gaussian',7,10)
V=.01
BlurredNoisy=imnoise(imfilter(I,PSF),'gaussian',0,V)
NOISEPOWER=V*prod(size(I))
[J LAGRA]=deconvreg(BlurredNoisy,PSF,NOISEPOWER)
subplot(221)imshow(BlurredNoisy)
title('A=Blurred and Noisy')
subplot(222)imshow(J)
title('[J LAGRA]=deconvreg(A,PSF,NP)')
subplot(223)imshow(deconvreg(BlurredNoisy,PSF,[],LAGRA/10))
title('deconvreg(A,PSF,[],0.1*LAGRA)')
subplot(225)imshow(deconvreg(BlurredNoisy,PSF,[],LAGRA/10))
subplot(224)imshow(deconvreg(BlurredNoisy,PSF,[],LAGRA*10))
title('deconvreg(A,PSF,[],10*LAGRA'敏敬)
3.Lucy-Richardson复原程序举例
%Lucy-Richardson复原程序
I=checkerboard(8)
PSF=fspecial('gaussian',7,10)
V=.0001
BlurredNoisy=imnoise(imfilter(I,PSF),'gaussian',0,V)
WT=zeros(size(I))
WT(5:end-4,5:end-4)=1
J1=deconvlucy(BlurredNoisy,PSF)
J2=deconvlucy(BlurredNoisy,PSF,20,sqrt(V))
J3=deconvlucy(BlurredNoisy,PSF,20,sqrt(V),[],WT)
subplot(221)imshow(BlurredNoisy)
title('A=Blurred and Noisy')
subplot(222)imshow(J1)
title('deconvlucy(A,PSF)')
subplot(223)imshow(J2)
title('deconvlucy(A,PSF,NI,DP)'租物)
subplot(224)imshow(J3)
title('deconvlucy(A,PSF,NI,DP,[],WT)')
4.盲去卷积复原
%盲去卷积复原
I=checkerboard(8)
PSF=fspecial('gaussian',7,10)
V=.0001
BlurredNoisy=imnoise(imfilter(I,PSF),'gaussian',0,V)
WT=zeros(size(I))
WT(5:end-4,5:end-4)=1
INITPSF=ones(size(PSF))
FUN=inline('PSF+P1','PSF','P1')
[J P]=deconvblind(BlurredNoisy,INITPSF,20,10*sqrt(V),WT,FUN,0)
subplot(221)imshow(BlurredNoisy)
title('A=Blurred and Noisy')
subplot(222)imshow(PSF,[])
title('True PSF')
subplot(223)imshow(J)
title('Deblured Image')
subplot(224)imshow(P,[])
title('Recovered PSF')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)