引言
這是圖像去模糊的第三篇,接着上節說道逆濾波對噪聲特別敏感。約束最小二乘方濾波(Constrained Least Squares Filtering,aka Tikhonov filtration,Tikhonov regularization)核心是H對噪聲的敏感性問題。減少噪聲敏感新問題的一種方法是以平滑度量的最佳復原爲基礎的,因此我們可以建立下列約束條件:
其約束條件爲
這裏,
推導
如何求解這個式子呢,將上式表示成矩陣形式,同時將約束項轉換成拉格朗日乘子項,可得到
最小化上代價函數,對
最後可得到,下列式子
這裏,
的傅里葉變換。其實這就是那個拉普拉斯模板嘛。
嗯,和書上的公式一模一樣,這就證明我們求解對了。
好了,我又可以重新造輪子了。
代碼
close all;
clear all;
clc;
% Display the original image.
I = im2double(imread('lena.jpg'));
[hei,wid,~] = size(I);
subplot(2,3,1),imshow(I);
title('Original Image (courtesy of MIT)');
% Simulate a motion blur.
LEN = 21;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
subplot(2,3,2), imshow(blurred); title('Blurred Image');
% Inverse filter
If = fft2(blurred);
Pf = psf2otf(PSF,[hei,wid]);
deblurred = ifft2(If./Pf);
subplot(2,3,3), imshow(deblurred); title('Restore Image')
% Simulate additive noise.
noise_mean = 0;
noise_var = 0.00001;
blurred_noisy = imnoise(blurred, 'gaussian', ...
noise_mean, noise_var);
subplot(2,3,4), imshow(blurred_noisy)
title('Simulate Blur and Noise')
% 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,5), imshow(deblurred2)
title('Restoration of Blurred Using Constrained Least Squares Filtering');
subplot(2,3,6); imshow(deconvreg(blurred_noisy, PSF,0)); title('Regul in Matlab');
依次是原圖,運動模糊圖像,逆濾波結果,運動模糊+高斯噪聲,Home Made 約束最小二乘方濾波(
效果
嗯,可以看出我們做出來的約束最小二乘方濾波效果非常不錯的(多虧我調的一手好參)。這裏的
其實
迭代計算γ
定義一個“殘差”向量
而
這裏我們需要明白的是
對於這個單變量函數,求其極小值可以藉助於matlab的fminbnd函數。
好了,這個系列已經接近尾聲了,可能就不在寫了。如果還有疑惑可以看一下matlab中deconvreg.m源文件。
還有關於實際運用需要估計核PSF,關於PSF的估計可以參看RESTORATION OF DEFOCUSED AND BLURRED IMAGES。上述介紹的都是比較傳統的方法,關於盲區卷積,可以在網上用谷歌搜索Deblur最近幾年發表的文章。
效果
更多閱讀
RESTORATION OF DEFOCUSED AND BLURRED IMAGES http://yuzhikov.com/articles/BlurredImagesRestoration1.htm
圖像去模糊 (維納濾波)http://blog.csdn.net/bluecol/article/details/46242355
圖像去模糊(逆濾波)http://blog.csdn.net/bluecol/article/details/47357717
數字圖像處理(第三版) 岡薩雷斯著 chapter 5,圖像復原與重建
MathLab source code, deconvreg.m
Licenses
作者 | 日期 | 聯繫方式 |
---|---|---|
風吹夏天 | 2015年8月8日 | [email protected] |