約束最小二乘方濾波去模糊
阿新 • • 發佈:2019-01-03
維納濾波要求未退化影象和噪聲功率譜已知。實際情景沒有這麼多先驗知識。約束最小二乘濾波僅要求噪聲方差和均值的知識。
假設g(x,y)的大小為
該演算法核心是
其約束為:
根據拉格朗日乘子法,代價函式:
關於
deconvreg(g,PSF,NOISEPOWER,RANGE)
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');