?? ch8_4_3.m
字號:
%%%%%%%%%%%%%%%%%%%%約束最小二乘濾波復原
%用真實的PSF函數和噪聲強度作為參數進行圖像復原
NP = V*prod(size(I)); % noise power
reg1 = deconvreg(BlurredNoisy1,PSF1,NP);
reg2 = deconvreg(BlurredNoisy2,PSF2,NP);
figure;
subplot(1,2,1);imshow(reg1);
title('Restored1 with NP');
subplot(1,2,2);imshow(reg2);
title('Restored2 with NP');
%調用edgetaper函數,減弱噪聲放大效應和振鈴現象
Edged1 = edgetaper(BlurredNoisy1,PSF1);
Edged2 = edgetaper(BlurredNoisy2,PSF2);
reg7 = deconvreg(Edged1,PSF1,NP/1.3);
reg8 = deconvreg(Edged2,PSF2,NP/1.3);
figure;
subplot(1,2,1);imshow(reg7);
title('Edgetaper effect1');
subplot(1,2,2);imshow(reg8);
title('Edgetaper effect2');
%已知相應的拉格朗日算子LARGA
[reg1 LAGRA] = deconvreg(BlurredNoisy1,PSF1,NP);
reg9 = deconvreg(Edged1,PSF1,[],LAGRA);
reg10 = deconvreg(Edged1,PSF1,[],LAGRA*100);
reg11 = deconvreg(Edged1,PSF1,[],LAGRA/100);
figure;
subplot(1,3,1);imshow(reg9);
title('true LAGRA');
subplot(1,3,2);imshow(reg10);
title('large LAGRA');
subplot(1,3,3);imshow(reg11);
title('small LAGRA');
另一程序
%%%%%%%%%%%%%%%%%%%% 盲卷積濾波復原
%圖像模糊化
I = imread('cameraman.tif');
figure;imshow(I);title('Original Image');
PSF = fspecial('motion',13,45);
figure; imshow(PSF,[],'notruesize');
Blurred = imfilter(I,PSF,'circ','conv');
figure; imshow(Blurred); title('Blurred Image');
%圖像復原
INITPSF = ones(size(PSF));%獲取函數的特征
[J P]= deconvblind(Blurred,INITPSF,30);%盲卷積,保留使用的PSF
figure; imshow(J);
figure; imshow(P,[],'notruesize');
WEIGHT = edge(I,'sobel',.28);%sobel算子提取邊緣
se1 = strel('disk',1);
se2 = strel('line',13,45);
WEIGHT = ~imdilate(WEIGHT,[se1 se2]);%膨脹操作,邊界像素設為零
WEIGHT = padarray(WEIGHT(2:end-1,2:end-1),[2 2]);
figure; imshow(WEIGHT);
P1 = P;%保存數據
P1(find(P1 < 0.01))=0;%修改PSF函數
%利用上面得到的WEIGHT進行盲卷積
[J2 P2] = deconvblind(Blurred,P1,50,[],WEIGHT);
figure; imshow(J2);
figure; imshow(P2,[],'notruesize');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -