Sunday, October 11, 2009

Activity 19: Restoration of Blurred Image

Introduction
In this activity, we restore a motion blurred image with Gaussian noise using a Weiner filter and a pseudo Weiner filter.

In the Fourier space, the degraded image is given by

where G is the degraded image, F is the original image, N is the noise, H is the transfer function given by

where T is the duration of exposure, a and b represents displacements along u and v respectively.

Methodology
A test image is first degraded using the above equations. Restoration follows using a Weiner filter given by

where Sn and Sf are the power spectrum of the noise and the original image respectively. However, in real world situations, it is seldom known the noise and the original image hence we use a Pseudo Weiner filter given by

where K is a constant.

Results
Below are our results for different parameter values. x-axis represents K values and y-axis are the F, C, Q values.

Figure 1. Restoration for the test image with motion blur parameters a=0.05, b=0.05 and T=1


Figure 2. Restoration for the test image with motion blur parameters a=0.05, b=0.03 and T=1

To quantify the restored images, we used Linfoot's criterion. F represents fidelity or the general similarity of the image, C is the structural content which gives the relative sharpness of the images and Q is the correlation quality which measures the alignment of peaks. Perfect reconstruction occurs when F=C=Q=1

From figures 1 and 2, the Weiner filter shows the best restoration, followed by the Pseudo Weiner with K=0.0001. As K becomes larger, more blurring is observed. Sharp reconstruction is observed at lower K values, however noise amplification is observed. At the extreme case where K=0, restored image is unrecognizable. The direction of the lines in K=0, reflects the parameters a and b. (refer also to figure 3)

Below is our full data (click to enlarge)


Figure 3. Full restoration data.

From figure 3, we can observed that higher T value (for our case, T=3) are restored more accurately compared to those with lower T (for our case, T=1).

For this activity, I'll give myself a 10 for completing the activity and for having satisfactory results.

Source of test image: http://www.armadaanime.com/poster-belldandy-field.jpg

Activity 18: Noise Model and Basic Image Restoration

Introduction
The objective of this activity is to restore images with noise using different restoration methods.

Methodology
First a test image is deliberately added with noise. The noise added have different probability distributions, namely

Gaussian

Rayleigh
Gamma
Exponential
Uniform
Salt & Pepper


To restore the images, mean filters are used. In this activity we used four filters. To get the pixel value of the restored image G at some pixel coordinate (x,y), we define an area S with dimension m x n enclosing (x,y) where we can compute for the mean. To compute for the mean, we used the following equations.

Arithmetic mean filter
Geometric mean filter
Harmonic mean filter
Contraharmonic mean filter, where Q can be positive or negative

For the test image, we used the image below.


Figure 1. Left: Test image. Right: Its corresponding PDF.

Results
Upon the addition of noise, we obtained the following images together with their PDFs. (click to enlarge)


Figure 2. Test image with noise added.

As evident in figure 2, upon addition of noise, the PDF of the original image takes the form of the distribution of the noise.

The following are the restored images. (click to enlarge) Here, we used a 3x3 area to compute the mean. Although not shown, the method is also tested for a 5x5 area. Using large area will result in a more blurred reconstruction.


Figure 3. Image restoration for image with Exponential noise.


Figure 4. Image restoration for image with Gamma noise.


Figure 5. Image restoration for image with Gaussian noise.


Figure 6. Image restoration for image with Rayleigh noise.


Figure 7. Image restoration for image with Salt & Pepper noise.


Figure 8. Image restoration for image with Uniform noise.

To check the quality of restoration, we should look back to the PDF of the original image. From our results, the image is much restored except for the exponential noise wherein all of methods fail. Notice that the white part of the original image is not recovered. Also notice that at the addition of noise, the exponential noise resulted in an almost unrecognizable image. The distribution is bias to black (i.e. close to zero grayvalues).

Salt & pepper noise is also another stubborn noise. Only the arithmetic filter shows satisfactory result. It is also observed that at positive Q, pepper noise is removed however white spots remain (i.e. salt noise). The effect is reversed for negative Q.

It is also observed the restored image have shifted PDFs in comparison with the original PDF. This is probably due to the averaging method used by the filter. To get an average of 1 or 255 (i.e. white) the area used must contain only white values which is impossible due to the presence of noise.

For this activity, I'll give myself a 10 for completing the activity together with the analysis and for having cute plots ^_^

Thanks to Gilbert Gubatan et al. for sharing the MODNUM toolbox for the Rayleigh noise.

Saturday, September 19, 2009

Activity 17: Photometric Stereo

Photometric stereo uses light intensity from different light sources to infer the shape of a three-dimensional surface. For this activity we used four images of a sphere illuminated with four light sources positioned at different locations. For each source, the corresponding images are the following



Figure 1. Images

The reconstruction is shown below


Figure 2. Reconstruction.

The reconstruction is imperfect as shown in figure 2. However, to some extent the 3D features of our object has been reconstructed.

For this activity, I'll give myself a 9 because my code uses lots of for loops.

Activity 16: Neural Network

This activity uses the same training and test sets as with the previous activities. The algorithm for the neural network requires us to "label" the classes that will be used for the training. These labels will then be used to classify the test set. If a test object gives an array similar to the "label" of a certain class, it is assigned to that class. Note that we used five nodes for the output layer. This was done so that there will be a high difference between classes.

Figure 1. Training set labels.

The implementation of the neural network is separated in two. One, with a learning rate of 0.1 while the other has a learning rate of 2.5. The results are shown below (click for a larger image)


Figure 2. Summary of results. Left: Learning rate = 0.1. Right: Learning rate = 2.5.

Cells with red shading indicates wrong classification. These false results are observed only with a neural network with low learning rate. For 2.5 learning rate, the classification is 100% accurate. Also, compared to the previous methods, neural network shows a sharp distinction between classes. The values shown in figure 2 demonstrate this.


For this activity, I'll give myself a 9 for completing the activity and for the effort of figuring out how to implement a five node output layer neural network.

Monday, September 14, 2009

Activity 15: Probabilistic Classification

This objective of this activity is similar to that of activity 14. Here we will be using the linear discriminant analysis formula given by


Where µi is mean of the features of class i, x is the matrix of the features of object k, C is the covariance matrix. The object k is assigned to class i that has maximum fi [1]

Here we used the same training set and test set as with activity 14. The result is shown below.

Table 1. Summary of result.


Again, the result shows 100% accuracy. The two coins are still close as with activity 14.

For this activity I'll give myself 10 for completing the activity.

Reference:
[1] Teknomo, Kardi. Discriminant Analysis Tutorial. http://people.revoledu.com/kardi/ tutorial/LDA/

Sunday, September 13, 2009

Activity 14: Pattern Recognition

For this activity, we tried to simulate the human brain’s capacity to differentiate objects. We extracted features of different objects that can be compared (e.g. RGB components, area, eccentricity, etc). If a test object has features that is close to the features of a certain class, we assign it to that class.

First a training set is prepared to have a basis of comparison. The test objects are the following






Figure 1. Training set.

The feature of each class is plotted (i.e. RG components, eccentricity).

Figure 2. Plot of the features of the training set.

To determine which class a test object belongs, we used the Euclidean distance


Where dj represents the distance to class j, x is a matrix containing the features of the test object (the superscript T means transpose) and mj is the mean of the features of the class j. The test object is assigned to the class that gives the largest d. The results are as follow

Table 1. Summary of results.

The result shows 100% accuracy of the method for the chosen test objects. However it should be noted the closeness of values for the coin test objects indicating that the method and/or the features chosen is insufficient to create a sharp distinction between very similar objects.

For this activity, I'll give myself a 10 for completing it and for having satisfactory results.

Wednesday, September 9, 2009

Activity 13: Correcting Geometric Distortions

Distortion is an example of monochromatic aberrations. Distortion arises because different areas of the lens have different focal length and different magnifications. There are two types of distortion positive or pincushion distortion and negative or barrel distortion. Ideally, a thin lens will have no distortion. [1]


Figure 1. Left: Barrel distortion. Right:Pincushion distortion. If there is no distortion, the above images will be regularly spaced grids.

For this activity, we are tasked to correct a distorted image by first assuming that the distorted image is just a linear transform of the ideal image and vice versa.


Figure 2. Coordinate transformation.

The transformation functions are assumed to be bilinear functions of the form



where x and y in the LHS are the pixel coordinates in the distorted image and the x and y in the RHS are for the ideal image. After finding the coordinate transform, we look for the grayvalue at the ideal image pixel locations using a bilinear interpolation.

For my distorted images, I used the ones below (Click for a larger view.)


Figure 3. Distorted images.

The results are the following. (Click for a larger view.)


Figure 4. Corrected images.

Then results show that the method is sufficient to correct distortion of small images.


For this activity, I'll give myself a 10 for satisfactory result. Note that the reconstructed image does not require anymore a second bilinear interpolation because no null pixels are found.

Reference
[1] E. Hecht (2002). Optics 4th edition. Addison Wesley , CA.