Wednesday, July 13, 2011

I believe

"Even if everybody thinks you're not... I still believe that you are"...

We are human beings... not perfect... but we shouldn't be deprived of the chance to improve ourselves and show the society the better side of us...

Just some random thoughts from a very lazy evening... I remember the time when I last spoke about this.

Friday, June 17, 2011

Happy weekend ^_^

And so my day ended very happily! I know God will not let things happen without lessons to be learned. I will always trust in You Lord...

What a happy weekend indeed!

I was just so scared

I've been used to presenting talks about my research... But today, I don't know. I just got so scared to people. My confidence in facing different people inclined to different areas of research dropped down... I'm frustrated... but I know, this gave me a very important lesson...


Sunday, January 23, 2011

get back that luck

It's been more than a year since I visited my blog. And oh yeah, I was still an undergraduate student when I last posted some stuffs (academic-related stuffs) here.

I just astonished and anxious about TIME. Yes, time flies so fast. It seems like it was only yesterday when I rushed my blogs, my papers, my thesis. And now, time for making another thesis is coming... again...

I am already a 2nd year Master of Physics student... and next semester.. YES, as in June-Nov 2011, I shall be defending my master's thesis.

I was quite lucky during my undergrad years because I was able to conduct experiments and gather data everytime I lack information to support my research topic. And because of my excitement to my research, I entered the graduate program immediately after graduating last November 2009.

Now, I am feeling a bit nervous about my research. One factor is that the laser I used before is now in trouble. The simmer LED doesn't turn on during the warm up time. My supervisor has already checked several parameters to resolve our problem, but unfortunately, until now it is still not lighting.

Given more than 6 months before the end of the 1st semester of AY 2011-2012, our group must get the laser back to operation. Many of us depend on it. We can't easily replace it because IT IS VERY COSTLY... T_T

I just hope to get back that luck and be able to debug the problem in our laser. ...


Monday, October 12, 2009

Activity 19 Restoration of blurred images

The main objective of this activity is to restore an image corrupted by a known degradation function and an additive noise using Mean square error (Weiner) filtering.
In order to perform this, we first choose a clean grayscale image containing some texts within. The chosen image is shown in Figure 1. This image was then degraded by adding a Gaussian noise with it. The discussion about this noise model has been stated in the previous activity.
To perform the restoration, a simple model adapted from the handout [1] is displayed in figure 2. The image is degraded by convolving the degradation function h(x,y) with the image f(x,y) and adding the Gaussian noise (x,y). Note that this is in spatial domain. In order to transform this to the frequency domain, we take the Fourier transform of the terms and apply equation 2 in the handout, given by:

where capital letters correspond to the Fourier transform of the functions.


Figure 1. Clean image

Figure 2. Model of image degradation and restoration.

If we assume that the image is blurred by a linear motion between the sensor and the image during the acquisition, the image then undergoes a planar displacement in the x and y direction which varies through time t. In order to obtain to total exposure at any point of the recording medium, the integral of the instantaneous exposure is taken over the time interval for which the imaging shutter is opened. And if the opening and closing of the shutter occurs instantaneously, we can isolate the image motion and arrive at the blurred image using the formula:

where T is the exposure time. This can also be expressed in the frequency domain which is equivalent to:

The degradation function H is estimated using the following expression

Note that the variables a and b correspond to the total distance from which the image is displaced in the x and y direction.

In order to employ Weiner filtering, we treat the the image and the noise as random processes and try to estimatesuch that its mean square error with the original image f is small. This is performed mathematically by using the the equations:

where
.
Alternatively, the expression for F above can be approximated by the equation:


where K is a constant. This is particularly used when we are dealing with spectral white noise such that the spectrum is constant.

By varying the parameters a b and T, we apply Gaussian noise and degrade the image. The results for this degradation process are shown in Figure2. Using the last two expressions for , we try to restore these blurred images and the are shown in Figures 3 and 4.








Figure 2. Degradation of the image using different values of a, b, and T
Upon increasing the values of a and b, image becomes more blurry. This is reasonable since upon increasing the distance for which the image is displaced along the x and y axis with respect to the recording medium, lesser the information about the image can be generated. And it is seen that at a=b= 0.1, most of the information regarding the image is lost.






Figure 3. Restoration of the image using Weiner Filtering

From the figure above, the quality of the degraded image was improved, although it was not totally recovered. And comparing the images before and after applying Weiner flitering, we can observe that some of the information regarding the original image were restored. However, among the four sets of images, the restoration for a=b=0.1 is poorest.







Figure 4. Restoration of the image using Weiner Filtering equation 2 for different K, a, b, and T.

After using the second equation for the Weiner filtering and using different values for K (0.005-0.01 with 0.001 interval), restoration of some information in the image was done. However, if we compared the result with Figure 3, it can be seen that richer image quality is obtained in the first expression. And after varying K, no significant difference was observed.

In this activity, I was able to restore the degraded image corrupted with a degradation function and a Gaussian noise model so I am giving myself a grade of 10.

Reference:
" Restoration of blurred images", Activity 18 Handout, Applied Physics 186.

Saturday, October 10, 2009

Activity 18 Noise model and basic image restoration

In this activity, we try to demonstrate the different types of noise and image restoration techniques. Similar to image enhancement technique, this method aims to improve the quality of images surrounded with noise. However, this technique is more of object type as compared to image enhancement technique which is subjective in nature.

The image below shows the clean image composed of three grayscale values. The corresponding probability distribution function (PDF) of the gray levels of the clean image is also shown together with the image.

Figure 1. Clean image and its PDF

The different noise models that are applied to the image above are as follows:

1. Gaussian noise
This model is also known as the normal noise model from which the PDF is given by:

where z is the gray level value, is the average, and is the standard deviation.

2. Gamma/Erlang noise
This model has a PDF equal to:

and the mean and variance are given by:

3. Exponential noise model
For this model, the PDF is given as:

and the mean and variance of the density are:

4. Rayleigh noise model
The PDF of the Rayleigh noise model is given by:


and the mean and variance are determine using the equations:

5. Uniform noise model
To determine the PDF, mean, and variance of this model, the following equations are used.





6. Impulse (Salt and Pepper) noise model
The PDF of this model is:


These noise models were simulated using the "grand" function available in Scilab programming language. The effect of the different noise model on the clean image is investigated and shown in Figure 2. Notice from the PDF of the different noise models that the graylevels of the image which were supposedly consisting of only three values become broad and occupied other graylevel values. Depending on the parameters of the noise model, the width of the broadening can be varied. From Figure 2, it can also be noticed that after adding a uniform noise to the image, the graylevels become very large in range such that the values from ~125 to 255 were covered.

Figure 2. Different noise models applied to the clean image

In order to improve the quality of the degraded image brought by the added noise, spatial filtering method is employed. The different filters that are utilized in this activity are as follows.

Arithmetic Mean Filter (AMF)

In this method, a window S_xy with dimensions m x n and centered at point (x,y) from the corrupted image g(x,y) is selected and the average values of g(x,y) in the area of the window is computed. This can be expressed mathematically as:

where f(x,y) is the restored image.

Geometric Mean Filter (GMF)

This filter is used by implementing the following formula for computing the restore image f(x,y).

Harmonic Mean Filter (HMF)
To restore the corrupted image brought by the addition of noise, this filter is employed by following the formula:

Contraharmonic Mean Filter (CMF)
This filter works by using the expression:


where Q is the order of the filter. Different values of Q yields the removal of either salt or pepper noise and it cannot eliminate both the salt and pepper at the same time.

By implementing the formula given for every filter, the corrupted images after adding the different noise models were restored and shown in the figures below together with the PDF of the restored images.

Figure 3. Restoration of image with Gaussian noise

Figure 4. PDF of the restored image contaminated with Gaussian noise
From the restored images and their corresponding PDF, Gaussian noise was partially eliminated. From the originally very noisy image, the different filters showed an enhancement of the image quality. By observing the PDF of the restored images after using the 4 filters discussed above, it can be seen that the graylevels of the image became narrower in range. However, the initially white part of the image was converted to some other grays values.

Figure 5. Restoration of image with Gamma noise

Figure 6. PDF of the restored image contaminated with Gamma noise

After applying the different filters on the image contaminated with Gamma noise, the characteristic of the image became better in such a manner that the PDF showed three peaks with graylevel values close to the original image. Among the four filters, contraharmonic filter exhibit the worst restoration because the corresponding PDF of the image which was treated still showed a broad graylevel values. This can be further improved by trying other values for Q.

Figure 7. Restoration of image with Exponential noise

Figure 8. PDF of the restored image contaminated with Exponential noise
For the exponential noise that was added to the image, the four filters were shown to be effective in restoring the originally uncontaminated image. However, observing the PDF of the image treated with an arithmetic mean filter, there is an appearance of other peaks aside from the three high peaks.

Figure 9. Restoration of image with Uniform noise

Figure 10. PDF of the restored image contaminated with Uniform noise

Figure 11. Restoration of image with Rayleigh noise

Figure 12. PDF of the restored image contaminated with Rayleigh noise
The restoration of the image with uniform and rayleigh noise was also successfully done the four spatial filters. By comparing the PDF of the initially very noisy image when uniform noise is added and the PDF after applying the filter, we can see that there is a large improvement on the quality of the image.

For the salt and pepper noise added to the image, it can be seen that contraharmonic mean filter works best among the four filters. Further investigation was done when this filter is applied for different Q. In order to evaluate the mechanism of the filter for every Q, I used four values of Q, from -2 to +2 with an increment of 1 and applied CMF to the image contaminated with salt and pepper noise. The corresponding images with their PDF are shown in Figures 15 and 16.

Figure 13. Restoration of image with Salt and Pepper noise


Figure 14. PDF of the restored image contaminated with Salt and Pepper noise


Figure 15. Restoration of image contaminated with salt and pepper noise using CMF at different Q.

Figure 16. PDF of the restored image after using CMF at different Q
From the plots above, notice that if Q is negative, salt noise is eliminated while for positive Q, pepper noise is removed.

The different noise model and spatial filters for image restoration are again utilized for another image and the results are shown below.




























For this activity, I was able to show the different noise models and their effects on the image as well as the image restoration using the discussed spatial filters. Since the objective of the experiment was met, I give myself a grade of 10.

Reference:

"Noise model and basic image restoration", Applied physics 186 Activity 18 Handout
image: http://www.inhabitat.com/wp-content/uploads/fostergianttower.jpg