盲去卷积原理及在图像复原的应⽤
前⾔
之前写过⼀篇,讲述了图像退化模型以及维纳滤波的作⽤。维纳滤波使⽤的前提是知道信号和噪声的功率谱,但在实际应⽤中较难得到,只能根据先验知识进⾏估计。
本⽂介绍盲去卷积复原算法,并在MATLAB中进⾏实验,和维纳滤波的复原效果进⾏⼀个对⽐。盲去卷积的⽅法有多种,本⽂主要介绍由fish提出的基于露西-理查德森(Richardson-Lucy)的盲去卷积算法。
盲去卷积原理
露西-理查德森算法属于图像复原中的⾮线性算法,与维纳滤波这种较为直接的算法不同,该算法使⽤⾮线性迭代技术,在计算量、性能⽅⾯都有了⼀定提升。
露西-理查德森算法是由贝叶斯公式推导⽽来,因为使⽤了条件概率(即算法考虑了信号的固有波动,因此具有复原噪声图像的能⼒)。贝叶斯公式如下:
结合图像退化/复原模型,可以得到迭代函数:
其中 fi 就是第i轮迭代复原图像,对应贝叶斯公式中的p(x),g是退化函数,对应贝叶斯公式的p(y|x),c为退化图像(c(y)dy意为在退化图像上积分),如果满⾜等晕条件,即图像各区域的模糊函数相同,则迭代公式可化简如下:
这就是路西-理查德森迭代公式,其中c是退化图像,g是退化函数,f是第k轮复原图像。如果系统的退化函数PSF(g(x))已知,只要有⼀个初始估计f就可以进⾏迭代求解了。在开始迭代后,由于算法的形式,估计值会与真实值的差距迅速减⼩,从⽽后续迭代过程f的更新速度会逐渐变慢,直⾄收敛。算法的另⼀优点就是初始值f>0,后续迭代值均会保持⾮负性,并且能量不会发散。
盲去卷积需要两步进⾏复原,原因是我们既不知道原始图像f,也不知道退化函数g。求解过程⽰意图如下:
即在第k轮迭代,我们假a设原始图像已知,即k-1轮得到的fk-1,再通过R-L公式求解gk,随后,再⽤gk求解fk,反复迭代,最后求得最终f和g。因此,在求解最初,我们需要同时假设⼀个复原图像f0和⼀个退化函数g0。迭代公式如下:
此外,有⼈采⽤这种盲去卷积⽅法进⾏了相关实验,下图为实验原图:
下图(a)左、右分别为附加标准差1.5%、10%泊松噪声的退化图像,图(b)左、右分别为1.5%的复原图像和PSF,图(c)为10%对应结果
盲去卷积MATLAB实验
将⼀幅原始图像,进⾏模糊处理(模拟⼤⽓湍流),分别使⽤维纳滤波(由于没加噪声,就是逆滤波)和盲去卷积进⾏复原,复原结果如下:
下⾯是⽹上到的有关盲去卷积的MATLAB程序,可以加深理解。
%% Deblurring Images Using the Blind Deconvolution Algorithm
%%盲反卷积算法复原图像
% The Blind Deconvolution Algorithm can be used effectively when no
% information about the distortion (blurring and noise) is known. The
% algorithm restores the image and the point-spread function (PSF)
% simultaneously. The accelerated, damped Richardson-Lucy algorithm is used
% in each iteration. Additional optical system (e.g. camera)
% characteristics can be used as input parameters that could help to
% improve the quality of the image restoration. PSF constraints can be
% passed in through a user-specified function
%在不知道图像失真信息(模糊和噪声)信息情况下,盲反卷积算法可以有效地加以利⽤。该算法%对图像和点扩展函数(PSF)的同时进⾏复原。每次迭代都使⽤加速收敛Richardson-Lucy %算法。额外的光学系统(如照相机)的特性可作为输⼊参数,帮助改善图像复原质量。可以通%过⽤户指定的函数对PSF进⾏限制
% Copyright 2004-2005 The MathWorks, Inc.
%% Step 1: Read Image
%%第⼀步:读取图像
% The example reads in an intensity image. The |deconvblind| function can
% handle arrays of any dimension.
%该⽰例读取⼀个灰度图像。| deconvblind |函数可以处理任何维数组。
I = imread('view.tif');
figure;imshow(I);title('Original Image');
%text(size(I,2),size(I,1)+15, ...
% 'Image courtesy of Massachusetts Institute of Technology', ...
%'FontSize',7,'HorizontalAlignment','right');
%% Step 2: Simulate a Blur
%%第⼆步:模拟⼀个模糊
% Simulate a real-life image that could be blurred (e.g., due to camera
% motion or lack of focus). The example simulates the blur by convolving a
% Gaussian filter with the true image (using |imfilter|). The Gaussian filter
% then represents a point-spread function, |PSF|.
% then represents a point-spread function, |PSF|.
%模拟⼀个现实中存在的模糊图像(例如,由于相机抖动或对焦不⾜)。这个例⼦通过对真实
%图像进⾏⾼斯滤波器模拟图像模糊(使⽤|imfilter|)。⾼斯滤波器是⼀个点扩展函数,
%|PSF|。
PSF=fspecial('gaussian',7,10);
Blurred=imfilter(I,PSF,'symmetric','conv'); %对图像I进⾏滤波处理;
figure;imshow(Blurred);title('Blurred Image');
%% Step 3: Restore the Blurred Image Using PSFs of Various Sizes
%%第三步:使⽤不同的点扩展函数复原模糊图像
% To illustrate the importance of knowing the size of the true PSF, this
% example performs three restorations. Each time the PSF reconstruction
% starts from a uniform array--an array of ones.
%为了说明知道真实PSF的⼤⼩的重要性,这个例⼦执⾏三个修复。PSF函数重建每次都是从统⼀%的全⼀数组开始。
%%
% The first restoration, |J1| and |P1|, uses an undersized array, |UNDERPSF|, for
% an initial guess of the PSF. The size of the UNDERPSF array is 4 pixels
% shorter in each dimension than the true PSF.
%第⼀次复原,|J1|和|P1|,使⽤⼀个较⼩数组,| UNDERPSF |,来对PSF的初步猜测。该
%UNDERPSF数组每维⽐真实PSF少4个元素。
UNDERPSF = ones(size(PSF)-4);
[J1 P1] = deconvblind(Blurred,UNDERPSF);
figure;imshow(J1);title('Deblurring with Undersized PSF');
%%
% The second restoration, |J2| and |P2|, uses an array of ones, |OVERPSF|, for an
% initial PSF that is 4 pixels longer in each dimension than the true PSF.
%第⼆次复原,|J2|和|P2|,使⽤⼀个元素全为1的数组,| OVERPSF|,初始PSF每维⽐真
%实PSF多4个元素。
OVERPSF = padarray(UNDERPSF,[4 4],'replicate','both');
[J2 P2] = deconvblind(Blurred,OVERPSF);
figure;imshow(J2);title('Deblurring with Oversized PSF');
%%
% The third restoration, |J3| and |P3|, uses an array of ones, |INITPSF|, for an
% initial PSF that is exactly of the same size as the true PSF.
%第三次复原,|J3|和|P3|,使⽤⼀个全为⼀的数组| INITPSF |作为初次PSF,每维与真正
%的PSF相同。
INITPSF = padarray(UNDERPSF,[2 2],'replicate','both');
[J3 P3] = deconvblind(Blurred,INITPSF);
figure;imshow(J3);title('Deblurring with INITPSF');
%% Step 4: Analyzing the Restored PSF
%%第四步:分析复原函数PSF
% All three restorations also produce a PSF. The following pictures show
% how the analysis of the reconstructed PSF might help in guessing the
% right size for the initial PSF. In the true PSF, a Gaussian filter, the
% maximum values are at the center (white) and diminish at the borders (black).
%所有这三个复原也产⽣PSF。以下图⽚显⽰对PSF重建分析的如何可能有助于猜测最初PSF的⼤%⼩。在真正的PSF中,⾼斯滤波器的最⾼值在中⼼(⽩),到边界消失(⿊)。
用subplot函数figure;
subplot(221);imshow(PSF,[],'InitialMagnification','fit');
title('True PSF');
subplot(222);imshow(P1,[],'InitialMagnification','fit');
title('Reconstructed Undersized PSF');
title('Reconstructed Undersized PSF');
subplot(223);imshow(P2,[],'InitialMagnification','fit');
title('Reconstructed Oversized PSF');
subplot(224);imshow(P3,[],'InitialMagnification','fit');
title('Reconstructed true PSF');
%%
% The PSF reconstructed in the first restoration, |P1|, obviously does not
% fit into the constrained size. It has a strong signal variation at the
% borders. The corresponding image, |J1|, does not show any improved clarity
% vs. the blurred image,.
%第⼀次复原的PSF,|P1|,显然不适合⼤⼩的限制。它在边界有⼀个强烈的变化信号。
%相应的图⽚|J1|,与模糊图像|Blurred|⽐没有表现出清晰度提⾼。
%%
% The PSF reconstructed in the second restoration, |P2|, becomes very smooth
% at the edges. This implies that the restoration can handle a PSF of a
% smaller size. The corresponding image, |J2|, shows some deblurring but it
% is strongly corrupted by the ringing.
%第⼆次复原的PSF,|P2|,边缘变得⾮常平滑。这意味着复原可以处理⼀个更细致的
%PSF。相应的图⽚|J2|,显得清晰了,但被⼀些“振铃”强烈破坏。
%%
% Finally, the PSF reconstructed in the third restoration, |P3|, is somewhat
% intermediate between |P1| and |P2|. The array, |P3|, resembles the true PSF
% very well. The corresponding image, |J3|, shows significant improvement;
% however it is still corrupted by the ringing.
%最后,第三次复原的PSF,|P3|,介于|P1|和|P2|之间。该阵列|P3|,⾮常接近真
%正的PSF。相应的图⽚,|J3|,显⽰了显着改善,但它仍然被⼀些“振铃”破坏。
%% Step 5: Improving the Restoration
%%第五步:改善图像复原
% The ringing in the restored image, |J3|, occurs along the areas of sharp
% intensity contrast in the image and along the image borders. This example
% shows how to reduce the ringing effect by specifying a weighting
% function. The algorithm weights each pixel according to the |WEIGHT| array
% while restoring the image and the PSF. In our example, we start by
% finding the "sharp" pixels using the edge function. By trial and error,
% we determine that a desirable threshold level is 0.3.
%在复原图像|J3|内部灰度对⽐鲜明的地⽅和图像边界都出现了“振铃”。这个例⼦说明了如何%通过定义⼀个加权函数来减少图像中的“振铃”。该算法是在对图像和PSF进⾏复原时,对每个%像元根据|WEIGHT|数组进⾏加权计算。在我们的例⼦,我们从⽤边缘函数查“鲜明”像元%开始。通过反复试验,我们确定理想的阈值为0.3。
%WEIGHT = edge(I,'sobel',.3);
WEIGHT = edge(Blurred,'sobel',.3);
%%
% To widen the area, we use |imdilate| and pass in a structuring element, |se|.
%为了拓宽领域,我们使⽤|imdilate|并传递⼀个结构元素|se|。
se = strel('disk',2);
WEIGHT = 1-double(imdilate(WEIGHT,se));
%%
% The pixels close to the borders are also assigned the value 0.
%在边界附近像素的值也被分配为0。
WEIGHT([1:3 end-[0:2]],:) = 0;
WEIGHT(:,[1:3 end-[0:2]]) = 0;
figure;imshow(WEIGHT);title('Weight array');
%%
% The image is restored by calling deconvblind with the |WEIGHT| array and an
% increased number of iterations (30). Almost all the ringing is suppressed.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论