Image Processing Toolbox | ![]() ![]() |
Deblurring with the Blind Deconvolution Algorithm
Use the deconvblind
function to deblur an image using the blind deconvolution algorithm. The algorithm maximizes the likelihood that the resulting image, when convolved with the resulting PSF, is an instance of the blurred image, assuming Poisson noise statistics. The blind deconvolution algorithm can be used effectively when no information about the distortion (blurring and noise) is known. The deconvblind
function restores the image and the PSF simultaneously, using an iterative process similar to the accelerated, damped Lucy-Richardson algorithm.
The deconvblind
function, just like the deconvlucy
function, implements several adaptations to the original Lucy-Richardson maximum likelihood algorithm, which address complex image restoration tasks. Using these adaptations, you can:
For more information about these adaptations, see Deblurring with the Lucy-Richardson Algorithm. In addition, the deconvblind
function supports PSF constraints that can be passed in through a user-specified function.
Creating a Sample Blurred Image
To illustrate blind deconvolution, this example simulates a blurred image by convolving a motion filter PSF with an image (using imfilter
).
I = imread('cameraman.tif'); figure; imshow(I); title('Original Image'); PSF = fspecial('motion',13,45);% Create the PSF figure; imshow(PSF,[]); title('True PSF'); Blurred = imfilter(I,PSF,'circ','conv');% Simulate the blur figure; imshow(Blurred); title('Blurred Image');
Image Restoration: First Pass
As a first pass at restoring the blurred image of the cameraman, call the deconvblind
function specifying the image and an initial guess at the PSF as arguments.
When you specify the PSF, you must estimate its size and the values it contains. Your guess at the size of the initial PSF is more important to the ultimate success of the restoration than the values in the PSF. To determine the size, examine the blurred image and measure the width of a blur (in pixels) around an obviously sharp object. For example, in the sample blurred image, you can measure the blur near the contour of the man's sleeve. Because your initial guess at the values in the PSF is less important than the size, you can typically specify an array of 1's as the initial PSF.
The following example shows a restoration where the initial guess at the PSF is the same size as the true PSF that caused the blur.
INITPSF = ones(size(PSF)); [J P]= deconvblind(Blurred,INITPSF,30); figure; imshow(J); title('Preliminary Restoration'); figure; imshow(P,[],'notruesize'); title('Preliminary Restoration');
This example specified an initial PSF that was the same size as the true PSF, i.e., the PSF used to create the blur. In a real application, you may need to rerun deconvblind
, experimenting with PSFs of different sizes, until you achieve a satisfactory result. The restored PSF returned by each deconvolution can also provide valuable hints at the optimal PSF size. See the Image Processing Toolbox Deblurring Demos for an example.
Image Restoration: Second Pass
Although the first pass did succeed in deblurring the image to some extent, the ringing in the restored image around the sharp intensity contrast areas is unsatisfactory. (The example deliberately eliminated edge-related ringing by using the 'circular'
option in imfilter
while creating a blurred image.) This example makes a second pass at deblurring, this time achieving a better result by using both the optional WEIGHT
array parameter and by refining the guess at the initial PSF, P1
.
Creating a WEIGHT Array. To reduce this contrast-related ringing, rerun the deconvolution, this time using the optional WEIGHT
array parameter to exclude areas of high-contrast from the deblurring operation. You exclude a pixel from processing by assigning the value 0
to the corresponding element in the WEIGHT
array. (See Accounting for Nonuniform Image Quality for information about WEIGHT
arrays.)
This example uses edge detection and morphological processing to create a WEIGHT
array. The edge
, strel
, and imdilate
functions detect the high-contrast areas in the image. Because the blur in the image is linear, the example dilates the image twice. (For more information about using these functions, see Morphological Operations.) To exclude the image boundary pixels (a high-contrast area) from processing, the example uses padarray
to assign the value 0 to all border pixels.
WEIGHT = edge(I,'sobel',.28); se1 = strel('disk',1); se2 = strel('line',13,45); WEIGHT = ~imdilate(WEIGHT,[se1 se2]); WEIGHT = padarray(WEIGHT([1:2 end-[0:1]],[1:2 end-[0:1]]),[2 2]); figure; imshow(WEIGHT); title('Weight array');
Constraining the Restored PSF. Before repeating the deconvolution with the WEIGHT
array, the example refines the guess at the PSF. The reconstructed PSF, P
, returned by the first pass at deconvolution shows a clear linearity (see the image of the Restored PSF in Image Restoration: First Pass). For the second pass, the example uses a new PSF, P1
, which is same as the restored PSF but with the small amplitude pixels set to 0.
P1 = P; P1(find(P1 < 0.01))=0; [J2 P2] = deconvblind(Blurred,P1,50,[],WEIGHT); figure; imshow(J2); title('Newly deblurred image'); figure; imshow(P2,[],'notruesize'); title('Newly reconstructed PSF');
Refining the Result
The deconvblind
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 use this feature, you must pass in both the blurred image and the PSF as cell arrays, for example, {Blurred}
and {INITPSF}
.
The deconvblind
function returns the output image and the restored PSF as cell arrays. The output image cell array contains these four elements:
output{1}
-- The original input image
output{2}
-- The image produced by the last iteration
output{3}
-- The image produced by the next-to-last iteration
output{4}
-- Internal information used by deconvblind
to know where to restart the process
The PSF output cell array contains similar elements.
The deconvblind
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, as well as the functional option that allows you to place additional constraints on the PSF reconstruction, see the Image Processing Toolbox Deblurring Demos.
![]() | Deblurring with the Lucy-Richardson Algorithm | Creating Your Own Deblurring Functions | ![]() |