Main Content

使用Lucy-Richardson算法的脱毛图像

这个例子展示了如何使用Lucy-Richardsonalgorithm to deblur images. It can be used effectively when the point-spread function PSF (blurring operator) is known, but little or no information is available for the noise. The blurred and noisy image is restored by the iterative, accelerated, damped Lucy-Richardson algorithm. You can use characteristics of the optical system as input parameters to improve the quality of the image restoration.

步骤1:阅读图像

The example reads in an RGB image and crops it to be 256-by-256-by-3. Thedeconvlucyfunction can handle arrays of any dimension.

I = imread("board.tif"); I = I(50+(1:256),2+(1:256),:); figure; imshow(I); title(“原始图像”); text(size(I,2),size(I,1)+15,...“图像由Alexander V. Panasyuk博士提供。”,,,,..."FontSize",7,"HorizontalAlignment",,,,"right"); text(size(I,2),size(I,1)+25,...“哈佛大学天体物理学中心”,,,,..."FontSize",7,"HorizontalAlignment",,,,"right");

图包含一个轴对象。The axes object with title Original Image contains 3 objects of type image, text.

Step 2: Simulate a Blur and Noise

模拟由于摄像机运动或缺乏焦点而可能会模糊的真实图像。由于随机干扰,该图像也可能嘈杂。该示例通过将高斯过滤器与真实图像相卷来模拟模糊(使用imfilter)。然后,高斯滤波器代表点传播函数,PSF

PSF= fspecial(“高斯”,,,,5,5); Blurred = imfilter(I,PSF,"symmetric",,,,"conv"); figure; imshow(Blurred); title(“模糊”);

图包含一个轴对象。The axes object with title Blurred contains an object of type image.

The example simulates the noise by adding a Gaussian noise of variancevto the blurred image (usingimnoise)。噪声差异vis used later to define a damping parameter of the algorithm.

v= .002; BlurredNoisy = imnoise(Blurred,“高斯”,,,,0,V); figure; imshow(BlurredNoisy); title("Blurred & Noisy");

图包含一个轴对象。The axes object with title Blurred & Noisy contains an object of type image.

步骤3:恢复模糊和嘈杂的图像

还原提供PSF的模糊和嘈杂图像,仅使用5个迭代(默认为10)。输出是与输入图像相同类型的数组。

luc1 = deconvlucy(BlurredNoisy,PSF,5); figure; imshow(luc1); title(“恢复图像,numit = 5”);

图包含一个轴对象。带有标题恢复图像的轴对象,numit = 5包含一个类型图像的对象。

步骤4:迭代探索修复

所得图像随着每次迭代而变化。为了研究图像恢复的演变,您可以按步骤进行反卷积:进行一组迭代,查看结果,然后恢复停止的迭代。为此,必须将输入图像作为单元格数组的一部分传递。例如,通过传递开始第一组迭代{Blurrednoisy}代替模糊as the input image parameter.

luc1_cell = deconvlucy({BlurredNoisy},PSF,5);

In that case the output,luc1_cell,成为一个单元格数组。单元输出由四个数字阵列组成,其中第一个是模糊image, the second is the restored image of classdouble,,,,the third array is the result of the one-before-last iteration, and the fourth array is an internal parameter of the iterated set. The second numeric array of the output cell-array, imageluc1_cell{2},与步骤3图像的输出阵列相同,luc1,除可能的类别外(单元输出始终给出了类的恢复图像double)。

To resume the iterations, take the output from the previous function call, the cell-arrayluc1_cell并将其传递到deconvlucy功能。使用默认编号的迭代号(NUMIT= 10). The restored image is the result of a total of 15 iterations.

luc2_cell = deconvlucy(luc1_cell,PSF); luc2 = im2uint8(luc2_cell{2}); figure; imshow(luc2); title(“恢复图像,numit = 15”);

图包含一个轴对象。带有标题恢复图像的轴对象,numit = 15包含一个类型图像的对象。

步骤5:通过阻尼控制噪声放大

最新图像,luc2,是15次迭代的结果。尽管它比5次迭代的早期结果都更加清晰,但图像会发展出“斑点”的外观。这些斑点与任何真实结构不符(将其与真实图像进行比较),而是将噪声拟合到数据中的结果。

To control the noise amplification, use the damping option by specifying theDAMPARparameter.DAMPARhas to be of the same class as the input image. The algorithm dampens changes in the model in regions where the differences are small compared with the noise. TheDAMPAR这里使用的等于3噪声的标准偏差。请注意,图像更顺畅。

DAMPAR = im2uint8(3*sqrt(V)); luc3 = deconvlucy(BlurredNoisy,PSF,15,DAMPAR); figure; imshow(luc3); title("Restored Image with Damping, NUMIT = 15");

图包含一个轴对象。The axes object with title Restored Image with Damping, NUMIT = 15 contains an object of type image.

The next part of this example explores the重量andsubsampleinput parameters of thedeconvlucy功能,使用模拟星图(为简单和速度)。

步骤6:创建示例图像

The example creates a black/white image of four stars.

i =零(32);i(5,5)= 1;i(10,3)= 1;i(27,26)= 1;i(29,25)= 1;数字;imshow(1-i,[],,"InitialMagnification",,,,"fit"); ax = gca; ax.Visible ="on";ax.xticklabel = [];ax.yticklabel = [];ax.xtick = [7 24];ax.xgrid ="on";ax.ytick = [5 28];ax.ygrid ="on";title("Data");

图包含一个轴对象。The axes object with title Data contains an object of type image.

步骤7:模拟模糊

该示例通过创建高斯滤波器来模拟恒星图像的模糊,PSF,,,,and convolving it with the true image.

PSF= fspecial(“高斯”,15,3);模糊= imfilter(i,psf,"conv",,,,"sym");

现在,模拟只能观察一部分恒星图像的相机(仅看到模糊)。创建一个加权函数数组,WT,其中包括在Blurredimage ("good" pixels, located within the dashed lines) and zeros at the edges ("bad" pixels - those that do not receive the signal).

wt =零(32);WT(6:27,8:23)= 1;缩写=模糊。*wt;

为了减少与边界相关的铃声,请应用edgetaperfunction with the given PSF.

cuteded = edgetaper(calimage,psf);数字;imshow(1个钳口,[],,"InitialMagnification",,,,"fit"); ax = gca; ax.Visible ="on";ax.xticklabel = [];ax.yticklabel = [];ax.xtick = [7 24];ax.xgrid ="on";ax.ytick = [5 28];ax.ygrid ="on";title("Observed");

图包含一个轴对象。观察到标题的轴对象包含类型图像的对象。

Step 8: Provide the WEIGHT Array

The algorithm weights each pixel value according to the weight array while restoring the image. In our example, only the values of the central pixels are used (whereWT= 1), while the "bad" pixel values are excluded from the optimization. However, the algorithm can place the signal power into the location of these "bad" pixels, beyond the edge of the camera's view. Notice the accuracy of the resolved star positions.

luc4 = deconvlucy(CutEdged,PSF,300,0,WT); figure; imshow(1-luc4,[],"InitialMagnification",,,,"fit"); ax = gca; ax.Visible ="on";ax.xticklabel = [];ax.yticklabel = [];ax.xtick = [7 24];ax.xgrid ="on";ax.ytick = [5 28];ax.ygrid ="on";title(“恢复”);

图包含一个轴对象。The axes object with title Restored contains an object of type image.

Step 9: Provide a finer-sampled PSF

deconvlucycan restore undersampled image given a finer sampled PSF (finer bysubsample时代)。为了模拟未解决的图像和PSF,示例箱Blurred图像和原始PSF,每个维度为两个像素。

Binned = squeeze(sum(reshape(Blurred,[2 16 2 16]))); BinnedImage = squeeze(sum(Binned,2)); Binned = squeeze(sum(reshape(PSF(1:14,1:14),[2 7 2 7]))); BinnedPSF = squeeze(sum(Binned,2)); figure; imshow(1-BinnedImage,[],"InitialMagnification",,,,"fit"); ax = gca; ax.Visible ="on";ax.XTick = []; ax.YTick = []; title("Binned Observed");

图包含一个轴对象。带有标题的轴对象观察到的轴对象包含一个类型图像的对象。

Restore the undersampled image,BinnedImage,,,,using the undersampled PSF,BinnedPSF。Notice that theluc5image distinguishes only 3 stars.

luc5 = deconvlucy(BinnedImage,BinnedPSF,100); figure; imshow(1-luc5,[],"InitialMagnification",,,,"fit"); ax = gca; ax.Visible ="on";ax.XTick = []; ax.YTick = []; title("Poor PSF");

图包含一个轴对象。The axes object with title Poor PSF contains an object of type image.

下一个示例还原不采样的图像(BinnedImage),这次使用较好的PSF(在A上定义subsample- 更精细的网格)。重建图像(luc6)解决了恒星的位置更准确ly. Note how it distributes power between the two stars in the lower right corner of the image. This hints at the existence of two bright objects, instead of one, as in the previous restoration.

luc6 = deconvlucy(binnedimage,psf,100,[],[],[],[],2);数字;imshow(1-luc6,[],,"InitialMagnification",,,,"fit"); ax = gca; ax.Visible ="on";ax.XTick = []; ax.YTick = []; title("Fine PSF");

图包含一个轴对象。The axes object with title Fine PSF contains an object of type image.

也可以看看

|||

Related Topics