June 10, 2004

- Make a square image. (add drawing
tools to ImageJ or use
**Sample Images / Miscl / facewramp.tiff**)**File -> New**menu, select**256**or**512**for the height and width.- Draw in it.
- Thick and thin lines using brush and pencil tools.
- Gray level ramp: select rectangle with the rectangle tool ,
use the
**Edit -> Draw Scale**menu, then the**Edit -> Draw Boundary**menu. - Other geometric shapes can be made using the various selection tools
and the
**Draw Boundary**menu.

- Save it if you want. I saved this image as
**Sample Images / Miscl / facewramp.tiff**

- Take the Fourier Transform:
**Process -> FFT -> FFT**menu.

I used the |
ImageJ |

- Make another image of the same size, and put a black dot right in the middle (actually, the position does not matter much) with one click of the brush tool . (Double clicking on the brush tool shows a dialog to set the brush diameter. I have used the default of 14 pixels.) Click on the oval selection tool , hold down the option key, drag a small circle. Then use Edit / Fill. (The fill value or color will be that of the color selection tool .. Click outside the circle selection tool to deselect it, or the FFT in the next step will be quite small.

ImageJ |

This will be the 'point spread' function with which to blur the image, and then deblur it. This is not a realistic point spread function for microscopes, which might look more like a Gaussian shaped peak, and would be the image from a point source.

- Take the FFT of the dot.
**Process -> FFT -> FFT**menu.

ImageJ |

The first image will now be blurred by convolving it with the second image.
Although this could be done in the spatial domain by making a convolution kernel
and using the **Process -> Convolve**
menu with a convolution kernel (14x14 array with 1's to match the black pixels
in the dot image), convolution by large kernels is done more quickly in the
frequency domain (using the FFT). Deconvolution (deblurring) must be done in
the frequency domain. In ImageJ, frequence domain
math such as this is available using Process / FFT / FD Math...

- Blur the face image with the dot image, by multiplying
the two FFT images together and taking the inverse transform of the result.
**Process -> Image Math**menu, with these settings:-
ImageJ

- which gives FFT5 as a result:

ImageJ |

In ImageJ, the steps work up to this point. However, the resulting product image is not considered a frequency domain image by ImageJ, so we can go no further using these images. The process can be done more directly using Process / FFT / FD Math. - see the green sections below.

- Take the inverse transform:
**Process -> FFT -> Inverse FFT**menu then,**Process -> FFT -> Swap Quadrants**menu

To make the blurred image in ImageJ, use **Process
/ FFT / FD Math ...**

To deblur the image, divide its FFT by the FFT4, the FFT of the point spread function.

- Make sure the above image is the top or active image.
- Take its transform:
**Process -> FFT -> FFT**menu. (FFT5 above is restored.) - Divide FFT5 by FFT4: Process Image Math menu, select these parameters:

- Then take the inverse transform,
**Process -. FFT -> Inverse FFT**, to restore the image:

The image has been restored exactly, because the point spread function used for deblurring was identical to the point spread function used for blurring, and there was no noise.

To deblur the blurry "result" image above in ImageJ, use FD math again:

I'm not sure why the image is inverted. Fix
with either |

Let's alter the point spread function by reducing the size of the dot slightly, and see the effect on the 'deblurred' image.

- Click on the dot image, or choose it in the Window menu, to make it the front image.
- Make it into a binary image
- double-click on the threshold tool
- move the red band in the LUT window if necessary, in order to make the dot red.
- Use the
**Process -> Binary -> Make Binary**menu.

- Erode a one pixel layer from the boundary using the
**Process -> Morphology -> Erode**menu.

In ImageJ, just use **Process / Binary / Erode**,
or **Process / Binary / Dilate,** then use Process / FFT / FD Math

where 'dot' is the now altered point spread function image. The result is unrecognizable. The point spread function was changed too much.

- Make a new 256 x 256 image (
**File -> New**menu. 256x256 should still be the default.) - Double-click on the brush tool , and set the diameter to 13 pixels (rather than 14).
- Click on the black bar in the LUT window to make the brush black if it is not already.
- Click once in the middle of the new window to make the black dot.

- Take the FFT of the new (corrupted) point spread function with the
**Process -> FFT -> FFT**menu. (the name of this window may be different - I had to start over).

- Divide the FFT of the blurred face image, by the above FFT7 for the new, corrupted point spread function.

- Take the Inverse FFT using the Process -> FFT -> Inverse FFT menu.

This image is barely recognizable. The point spread function has to be known well for good deblurring. You might wish to experiment with other point spread functions that are less corrupted.

- Duplicate the original dot used for the blurring point spread function, zoom it several times with the eyeglass tool. It will look like this:

.

- Using the pencil tool, modify four pixels in the image so that it looks like this:

.

- Take the FFT (Process -> FFT -> FFT) of the new dot.

- Divide the FFT of the original blurred image (FFT of original image
X FFT of original dot) by the FFT of the new corrupted dot. (
**Process -> Image Math**... menu. Make sure the operation is**divide**).

- And, finally, take the inverse transform (
**Process -> FFT -> Inverse FFT**menu.)

Evidently, the point spread function must be known very accurately.