Monday, October 12, 2009

Activity 19 - Restoration of Blurred Image

Blurring of images can be result of the "spreading effect" caused by the transfer function of the imaging device, such as camera, as it images the object. This transfer function may be internal to the camera, due to its limited resolution. However, an additional factor is upon the capturing of the image. In most cases, motion blur affects the imaging perhaps due to the relative movement of the camera and the scene or object being captured with respect to each other.
The uniform linear motion causing this blurring can help model and provide a basis of removing motion blur in images. From the equation:
where f is the object image, and g is the blurred image, the blurring is attributed to a uniform linear motion along x and y, namely xo(t) and yo(t), respectively, for a given total time T. The total time T corresponds to the total time the camera captures the motion (exposure time). The effective transfer function of the motion blur can be obtained from the previous equation by taking its Fourier transform, and isolating the known form of the Fourier transform of the object image. All the other factors can be considered as the transfer function of the motion blur:
where G and F represents the Fourier transform of the blurred and original image. H is the motion blur transfer function, with xo(t) and yo(t) expressed as at/T and bt/T, respectively. This suggests that the amplitude or extent of the motion blur along x and y is dictated by a and b, respectively.
Motion blur can then be easily removed from an image upon knowing the proper parameters for the transfer function. However, when noise is present, the restoration is not straightforward division of this transfer function from the blurred image. Filtering methods are applied for restoring noisy and motion-blurred iamges. One filter, the Wiener filter, was basically derived such that the mean square error between the original and reconstructed image was minimized. This filter is also called minimum square error filter. The reconstruction is summed up in the equation:

where N is the Fourier transform of the noise. In reality, the noise and the original image cannot be obtained directly, which is why this factor in the equation above is replaced by K:
Optimizing the reconstruction rests on choosing the right value for K.
Using the description of the motion blur model, blurring and addition of Gaussian noise was simulated in this activity. This image was restored using the Wiener filter to determine the effect of certain parameters.
The images below show the original and the blurred image with noise mean and standard deviation at 0.01. The parameters for the blurring is set as a,b=0.01, and T = 1. The degradation is clearly seen in the blurred image.

In restoring the blurred image, K was varied to determine its effect in the reconstruction. The results are shown below
Notice that the decrease in K results into removing the blur of the image, however, it becomes noisy upon further decrease. This is the tradeoff in the adjustment for K, especially if the power of the noise added is very large.
If the added noise is decreased, and the reconstruction used was the Wiener filter with the factors of the noise and the original image (ratio of power spectrum of noise and original image), the reconstruction improves as the noise is lessened. This means that the reconstruction is very sensitive to noise. Notice that the reconstruction of the images below show a better quality since the reconstruction is directly based on the information of the noise and the original image.

This is also verified for varying K, as presented in the set of images below with the noise mean and standard deviation at 0.001. A good reconstruction is already attained K=0.001 unlike the previous results for a stronger noise.

In increasing the amplitude of the blur (a,b = 0.1), the restoration would provide more problems for adjusting the parameters. As seen below, using the noise mean and standard deviation at 0.001, the reconstruction was still undesirable at K=0.0001, in contrast with the results obtained in the previous set of images.
To improve the reconstruction for the larger amplitude of the motion blur, the effect of T was determined. Notice from the set of images below, that a better reconstruction was obtained using a larger value for T, using the same value of K. This would help in the tradeoff between removing noise and removing motion blur upon adjusting K. If the removal of blur is insufficient for a value of K, T may be adjusted.
From the analysis of the effect of different parameters in the restoration, the ideal parameters can be easily determined for restoring a blurred image with noise. This provides an effective way of obtaining quality images, instead of wasting film, memory space or even time from capturing those undesirable blurry images.
For this activity, I would like to give myself a grade of 10 for successfully implementing the motion blur model and the Wiener filter restoration. I think I have also provided a sufficient analysis of the effects of the different parameters.
I would like to thank Dr. Gay Jane Perez for her guidance in this activity.

Reference:
R. Gonzalez, R. Woods, Digital Image Processing, Chapter 5, Prentice Hall, Inc., New Jersey, 2002.

Activity 18 - Noise Models and Basic Image Restoration

Unwanted signals are hard to eliminate upon detection due to its random nature. In imaging, for every captured image, these unwanted signals in the form of noise do not take the same form in all the images, i.e., the noise detected at a pixel may no longer occur or may not have the same value for another image captured at the same pixel. It is important in image restoration to filter out these noise.
Modeling the noise added to an image is one way of analyzing the effect of noise, and in turn, for studying the use of different approaches to eliminate this noise. The randomness of noise is basis for the creating noise by generating images with probability distribution functions (PDFs) of the graylevels following the commonly random distributions: Erlang (Gamma), Exponential, Gaussian (Normal), Rayleigh, Salt and Pepper (Impulse), and Uniform.
Removing noise from images requires some filtering methods, whether in real or inverse space. In this activity, filtering is done in the real space using different methods. The filters tackled here mainly uses a window over which several (statistical) operations are carried out on the image with the effect of changing the grayvalue of a pixel in which the center of the window is located. The operations describe the filters used, namely, the arithmetic mean filter, geometric mean filter, harmonic mean filter, and contraharmonic mean filter. The main objective is to observe the effectivity of noise filtering using different filters and parameters used, such as the size of the window.
First, the noise models were added to the sample image shown below. The original PDF of the image contains three spikes at the grayvalues of the 3 regions, the black background, the gray square, and the near white circle. Adding the noise effectively broadens these spikes such that they overlap. The contrast of the images are degraded as seen visually upon the addition of noise. Using the different filters, the image is restored. In comparing the different filters, the original noisy image is compared with the restored images using arithmetic mean, geometric mean and harmonic mean filters, and then with the contraharmonic mean filter using different values of the parameter Q. The corresponding histogram of the images are shown after each set of images.
Original image
Window size: 5x5

Erlang (Gamma)


Exponential

Gaussian (Normal)

Rayleigh
Salt and Pepper (Impulse)

Uniform

The different image restoration results that were observed showed that indeed, the image is improved especially in the contrast, as compared to the noisy image. In the histogram, the broadening of the three peaks brought about by the added noise was minimized such that histogram of the three regions no longer overlap to some extent. Interestingly, the histogram for each region upon restoration appears in a Gaussian distribution (except for impulse noise).
The results for impulse noise using the contraharmonic filter verify the effect of the parameter Q. Indeed, the positive Q values remove pepper noise but results to enhancing the salt noise. On the other hand, negative Q values remove salt but not pepper noise. For the occurrence of both, it is ideal to used Q=0.
Using other filters depend on the noise (type, strength, etc.) added on the image. Depending on the use of the image or whether a person is satisfied with the result, the right filter (with proper parameters) can be determined, whether visually, or in the histogram.
The window size chosen here is 5x5, which translates to operations over a 5x5 pixel array. As seen in the results, the separation between the regions is no longer defined. It appears smeared due to the operation over a large pixel array. This would also translate to details becoming blurred or may even be totally removed due to the smearing. In such cases, it is better to use smaller window sizes to retain the information. However, there is a tradeoff because larger window sizes would provide better noise filtering, since statistics is based on more values. Again, this translates to adjusting the parameters depending on the purpose of use of the restored images. This may also be helpful whether details of the image are directional, for example, if outlines in the image are along the horizontal, then a 5x3 window size can be used, to filter noise well without affecting the details of the image.

Original image
For the next set of images, a grayscale image of Lotus (shown above) was added with noise. Since this has more details compared to the previous image used, a smaller window size (3x3) is used. The PDFs of the noise image do not have a significant region of separation so it is interesting to see how much improvement can be obtained.

Erlang (Gamma)
Exponential

Gaussian (Normal)

Rayleigh

Salt and Pepper (Impulse)
Uniform

Image restoration for this set of images was clearly obtained. The histogram of the images were "stretched" such that the contrast as seen visually are improved. This demonstrates that the method for noise filtering is effective. The same effect of positive and negative Q values for the contraharmonic filter were also observed in the impulse noise. It can also be observed that the harmonic mean filter is a very flexible technique (applicable for all noise distributions) and is very reliable in restoring the image.
For this activity, I would like to give myself a grade of 10 for successfully creating and adding the noise models and implementing the different noise filters.
I would like to thank Jay Samuel Combinido, Mark Jayson Villangca, and Miguel Sison for their help in this activity, and also for the guidance of our professor, Dr. Gay Jane Perez.