1. 程式人生 > >約束最小二乘方濾波去模糊

約束最小二乘方濾波去模糊

維納濾波要求未退化影象和噪聲功率譜已知。實際情景沒有這麼多先驗知識。約束最小二乘濾波僅要求噪聲方差和均值的知識。

g=Hf+η
假設g(x,y)的大小為M×N,g(x,y)第一行的影象元素構成向量g的第一組N個元素,第二行構成下一組N個元素,結果向量MN×1維,矩陣HMN×MN維,這樣轉換增加了H矩陣維度,且對噪聲高度敏感,問題更加複雜。
該演算法核心是H對噪聲的敏感性問題。減小噪聲敏感性問題的一種方法是以平滑度量的最佳復原為基礎的,如一副影象的二階導數,期望找到最小準則函式C:
C=x=0M1y=0N1[2f(x,y)]2
其約束為:
||gHf^||2=||η||2
根據拉格朗日乘子法,代價函式:
|
|pf^||2+λ(||gHf^||2||η||2)

關於f^求導:
f^=λHgλHH+PP=HgHH+γPP
p=010141010
這裡寫圖片描述
deconvreg(g,PSF,NOISEPOWER,RANGE)

g是未被汙染影象,NOISEPOWER與||η||2成比例,RANGE為值的範圍。預設範圍[109,109],將上述兩個引數排除在引數之外產生逆濾波方案,針對NOISEPOWER比較好的估計是MN[σ2η+ση2]。NOISEPOWER可以得到較好的結果。

close all;
clear all;
clc;
% Display the original image.
I
= imread('1.jpg'); [d1,d2,d3] = size(I); if(d3 > 1) I = rgb2gray(I); end I = im2double(I); [hei,wid,~] = size(I); subplot(2,3,1),imshow(I); title('Original Image '); % Simulate a motion blur. LEN = 100; THETA = 11; PSF = fspecial('motion', LEN, THETA); blurred = imfilter(I, PSF, 'conv', 'circular'
); subplot(2,3,2), imshow(blurred); title('Blurred Image'); % Simulate additive noise. noise_mean = 0; noise_var = 0.00001; blurred_noisy = imnoise(blurred, 'gaussian', ... noise_mean, noise_var); subplot(2,3,3), imshow(blurred_noisy) title('Simulate Blur and Noise') If = fft2(blurred); Pf = psf2otf(PSF,[hei,wid]); % Try restoration using Home Made Constrained Least Squares Filtering. p = [0 -1 0;-1 4 -1;0 -1 0]; P = psf2otf(p,[hei,wid]); gama = 0.001; If = fft2(blurred_noisy); numerator = conj(Pf);%計算共軛 denominator = Pf.^2 + gama*(P.^2); deblurred2 = ifft2( numerator.*If./ denominator ); subplot(2,3,4), imshow(deblurred2) title('Restoration of Blurred Using Constrained Least Squares Filtering'); subplot(2,3,5); imshow(deconvreg(blurred_noisy, PSF,10e1)); title('Regul in Matlab');