Thursday, November 14, 2013

Fourier: Convolution and Deconvolution




Convolution is not an operation only specific of real space filters. You can use it in frequency space. Its counterpart - the deconvolution - is also very popular to enhance images.


Imagine a romantic scene: a dark sky with beautiful stars ... Unfortunately, you are nearsighted or your binoculars are too limited and the stars appear as blurred disks...

1- Convolution in frequency space

Let us come back to our topic. First, create the sky as a new 32-bit image of 256x256 entitled 'sky' with a black background in File > New > Image... Then, using the pencil tool (Tool #16), draw several stars as white dots (Fig.1) by selecting the white color (R=255; G=255; B=255) in the color dialog box.

Fig1: Starry sky. An ideal image without defect.


The image of Fig.1 represents a perfect image without any kind of distortions or defects. Now, an easy way to simulate the myopia (or low resolution binoculars) is to blur this image. In real space, we can apply a gaussian filter available in Process > Filters > Gaussian Blur (choose Sigma: 6.0).

Note: You can do exactly the same in frequency space. First, you need to create a gaussian blurred kernel.
Fig.2: Mask corresponding to a gaussian kernel
Now, go to Process > FFT > FD Math and select  'sky' (Image 1), 'Convolve' as operator and 'gauss' (Image 2), you get the image of Fig. 3. This is exactly the same result as applying the previous Gaussian Blur filter.

Fig.3: Blurred stars...

2- Point Spread Function


The image of Fig.2 (the mask) is called a 'Point Spread Function' (PSF) because a dot in the ideal image is imaged as a splatted blob (like a snowball thrown at a wall) by the experimental device. This PSF is directly related to the optical constraints of the acquisition device (optical, confocal, electron microscopes, etc.).

3- Deconvolution

3-1- Deconvolution with Process > FFT > FD Math
Deconvolution is the reverse operation of convolution.
Open the dialog box of Process > FFT > FD Math, choose image of Fig.3, 'Deconvolve' as operator and image of Fig.2 (the mask), the image of Fig.1 is retrieved without defect. Great!!
3-2- Try to find out the PSF of an unknown image.
For example, the image in Fig.4 corresponds to our starry sky but during the acquisition, the operator has moved.

Fig.4: Move during the image acquisition of the starry sky.

In that case, we assume that the stars are dots and thus, what we see in Fig. 4 is the shape of the transfer function. Just select one oblique line, duplicate and pad it in a 256x256 image. Then, deconvolve the image of Fig. 4 with this transfer function. The stars appear now as dots but shifted because it is dependent of the way you select the oblique line.
In real world, this is not so simple and there is more sophisticated techniques known as blind deconvolution to solve this problem.

4- Mini games


Several mini-games of CrazyBioComputing are based on Fourier operations like convolution/deconvolution. They are located in level #9   [Link].

 5-Links

Table of Contents of the section 'Processing' [Link]

No comments:

Post a Comment