Accelerating the pace of engineering and science

# Documentation

## Deblurring with the Lucy-Richardson Algorithm

### Overview

Use the deconvlucy function to deblur an image using the accelerated, damped, Lucy-Richardson algorithm. The algorithm maximizes the likelihood that the resulting image, when convolved with the PSF, is an instance of the blurred image, assuming Poisson noise statistics. This function can be effective when you know the PSF but know little about the additive noise in the image.

The deconvlucy function implements several adaptations to the original Lucy-Richardson maximum likelihood algorithm that address complex image restoration tasks.

### Reducing the Effect of Noise Amplification

Noise amplification is a common problem of maximum likelihood methods that attempt to fit data as closely as possible. After many iterations, the restored image can have a speckled appearance, especially for a smooth object observed at low signal-to-noise ratios. These speckles do not represent any real structure in the image, but are artifacts of fitting the noise in the image too closely.

To control noise amplification, the deconvlucy function uses a damping parameter, DAMPAR. This parameter specifies the threshold level for the deviation of the resulting image from the original image, below which damping occurs. For pixels that deviate in the vicinity of their original values, iterations are suppressed.

Damping is also used to reduce ringing, the appearance of high-frequency structures in a restored image. Ringing is not necessarily the result of noise amplification. See Avoiding Ringing in Deblurred Images for more information.

### Accounting for Nonuniform Image Quality

Another complication of real-life image restoration is that the data might include bad pixels, or that the quality of the receiving pixels might vary with time and position. By specifying the WEIGHT array parameter with the deconvlucy function, you can specify that certain pixels in the image be ignored. To ignore a pixel, assign a weight of zero to the element in the WEIGHT array that corresponds to the pixel in the image.

The algorithm converges on predicted values for the bad pixels based on the information from neighborhood pixels. The variation in the detector response from pixel to pixel (the so-called flat-field correction) can also be accommodated by the WEIGHT array. Instead of assigning a weight of 1.0 to the good pixels, you can specify fractional values and weight the pixels according to the amount of the flat-field correction.

Noise in charge coupled device (CCD) detectors has two primary components:

• Photon counting noise with a Poisson distribution

• Read-out noise with a Gaussian distribution

The Lucy-Richardson iterations intrinsically account for the first type of noise. You must account for the second type of noise; otherwise, it can cause pixels with low levels of incident photons to have negative values.

The deconvlucy function uses the READOUT input parameter to handle camera read-out noise. The value of this parameter is typically the sum of the read-out noise variance and the background noise (e.g., number of counts from the background radiation). The value of the READOUT parameter specifies an offset that ensures that all values are positive.

### Handling Undersampled Images

The restoration of undersampled data can be improved significantly if it is done on a finer grid. The deconvlucy function uses the SUBSMPL parameter to specify the subsampling rate, if the PSF is known to have a higher resolution.

If the undersampled data is the result of camera pixel binning during image acquisition, the PSF observed at each pixel rate can serve as a finer grid PSF. Otherwise, the PSF can be obtained via observations taken at subpixel offsets or via optical modeling techniques. This method is especially effective for images of stars (high signal-to-noise ratio), because the stars are effectively forced to be in the center of a pixel. If a star is centered between pixels, it is restored as a combination of the neighboring pixels. A finer grid redirects the consequent spreading of the star flux back to the center of the star's image.

### Example: Using the deconvlucy Function to Deblur an Image

To illustrate a simple use of deconvlucy, this example simulates a blurred, noisy image by convolving a Gaussian filter PSF with an image (using imfilter) and then adding Gaussian noise of variance V to the blurred image (using imnoise):

1. Read an image into the MATLAB® workspace. (The example uses cropping to reduce the size of the image to be deblurred. This is not a required step in deblurring operations.)

```I = imread('board.tif');
I = I(50+[1:256],2+[1:256],:);
figure, imshow(I)
title('Original Image')
```

2. Create the PSF.

`PSF = fspecial('gaussian',5,5);`
3. Create a simulated blur in the image and add noise.

```Blurred = imfilter(I,PSF,'symmetric','conv');

V = .002;
BlurredNoisy = imnoise(Blurred,'gaussian',0,V);
figure, imshow(BlurredNoisy)
title('Blurred and Noisy Image')```

4. Use deconvlucy to restore the blurred and noisy image, specifying the PSF used to create the blur, and limiting the number of iterations to 5 (the default is 10).

 Note   The deconvlucy function can return values in the output image that are beyond the range of the input image.
```luc1 = deconvlucy(BlurredNoisy,PSF,5);
figure, imshow(luc1)
title('Restored Image')```

### Refining the Result

The deconvlucy function, by default, performs multiple iterations of the deblurring process. You can stop the processing after a certain number of iterations to check the result, and then restart the iterations from the point where processing stopped. To do this, pass in the input image as a cell array, for example, {BlurredNoisy}. The deconvlucy function returns the output image as a cell array that you can then pass as an input argument to deconvlucy to restart the deconvolution.

The output cell array contains these four elements:

Element

Description

output{1}

Original input image

output{2}

Image produced by the last iteration

output{3}

Image produced by the next to last iteration

output{4}

Internal information used by deconvlucy to know where to restart the process

The deconvlucy function supports several other optional arguments you can use to achieve the best possible result, such as specifying a damping parameter to handle additive noise in the blurred image. To see the impact of these optional arguments, view the Image Processing Toolbox™ deblurring examples.