Monday, October 5, 2009

Activity 18 | Noise Models and Basic Image Restoration

Image restoration is a basic image processing application where an image that has been degraded or damaged is being recovered. To recover the image, the degradation must be known and thus can be used in restoring the image.

A common source of degradation is the presence of noise in the image. Noise can hide useful information in an image. It is acquired mostly during image acquisition and transmission. Noise is composed of random values that follows a distribution which is expressed by a Probability Density Function of PDF. Figure 1 shows the respective PDFs of the different noise types to be used in this activity.


Figure 1. PDFs of different noise types.

In this activity we implement basic image restoration of noisy images using different filters. We use a test pattern shown by Figure 3 along with its PDF and then add noise to the image which will be used as the image to be restored. In restoring the noisy images, four different types of filtering, shown by Figure 2. are investigated for each type of noise.


Figure 2. Types of filtering used.


Figure 3. Test image and its PDF.

It can be seen that each peak in the PDF of the original test image has spread into the shape of the distribution added noise of the such that the three gray levels are almost coinciding with each other. This is the degradation that is done when adding noise. The same goes for the other distributions. The PDFs of the restored images simply shows how the filters restore the image which is by filtering out the unwanted gray values by thus thinning the fattened distribution for each peak gray value.

Figure 4 shows the noisy image for the added Gaussian noise with mean = 0.5 and standard deviation = 0.8. The resulting restored images using the five filters were almost the same achieving the three distinct gray value peaks which is close enough to the original.


Figure 4. Image with gaussian noise and restored images.

Figure 5 shows the noisy image for the Rayleigh Distribution. From the PDFs of the restored images, it can be said that the restored images using the arithmetic and geometric mean filter were much better than the other filters.


Figure 5. Image with rayleigh noise and restored images.

For the image with Gamma Noise shown in Figure 6, all the filters produced almost the same restored images except for the +Q Contraharmonic filter where the spread of the gray values is still visible.


Figure 6. Image with gamma noise and restored images.

The test image added with Exponential Noise is shown in Figure 7 and the restored image using the +Q Contraharmonic is clearly not a good result which is obvious from the image itself. Looking at the PDF for this restored image shows that the peaks were just shifted and broadened thus resulting to the noisy image.


Figure 7. Image with exponential noise and restored images.

Uniform Noise added image shown in Figure 8 shows great degradation due to the shape of the distribution itself where the is no defined peak value. Here, the arithmetic mean filter seems to have produced the best results although the peak gray values are shifted resulting to a lighter gray value for the area that is supposed to be black.


Figure 8. Image with uniform noise and restored images.

For the Salt and Pepper Noise it can be seen that the arithmetic mean filter just blurs the salt and pepper noise thus smoothening it out. It can also be noted that the +Q contraharmonic filter filters out the pepper noise while the geometric, harmonic and -Q contraharmonic filters can filter out the salt noise.


Figure 9. Image with impulse or salt and pepper noise and restored images.

The arithmetic mean filter basically blurs the image to smooth out the noise. The noise models and image restoration filters are also applied to a grayscale image which was used in a previous activity. The following series of images show the image with the different added noise types and the corresponding restored images using the five filters.








I give myself a grade of 10 for this activity.

Wednesday, September 9, 2009

Activity 17 | Photometric Stereo

Light when shone upon an object gives us an idea on the reflectance of that object that can be used in obtaining information about the object like color. The information stored in an objects reflectance due to a light source is used in many image processing methods which we have explored in the previous activities. Aside from the information that we have been using, we can also obtain the profile or the structure of the object by using images of the object with different light source positions and reconstruct the 3D structure of that object. This is what we call Photometric Stereo.

When light illuminates an object it produces shadows and color gradients all throughout the illuminated surface. And by getting images of the object at different light source locations, we obtain intensity profile of the whole illuminated surface. Different light sources also affect the intensity profile of the captured image of an object. Figure 1 shows the basic idea of Photometric Stereo where the angle in which light hits the surface of the object affects the captured intensity given by Equation 1 for a light source at infinity for that point P.


Figure 1. Photometric Stereo.


Equation 1. Intensity at point P(x,y).

In this activity, we use four images of an object taken with different light source positions and use it to reconstruct the 3D structure of the illuminated area, as shown by Figure 2.



Figure 2. Images of object at different light source positions.

To calculate for the surface normal of the object we need to get the far away point source locations given by V which was already provided, and the intensity I which is simply the images . The equations needed for calculating the surface normal is shown in Figure 2.


Figure 3. Equations needed for solving the surface normal.

After getting the surface normal, we can now compute for the surface elevation of the object at point (u,v) which is given by z = f(u,v) as shown in the equation below.



Figure 4. Surface elevation at point (u,v).

The resulting reconstructed 3D surface is shown below in Figure 5. We can see that the reconstructed surface is not smooth having jagged peaks and grooves. Also there is a concave dip at the areas where a transition in the intensity is located by comparing it to the four object images shown previously. All in all, the semi-spherical shape obtained matches the expected structure of the object from the images. I give myself a grade of 9 in this activity due to the roughness of the reconstructed surface.


Figure 5. Reconstructed 3D surface of object.

Activity 16 | Neural Networks

We have already investigated and implemented two methods for object classification using object features which are Minimum Euclidean Distance and Linear Discriminant Analysis. Another method that can be used for object classification is Neural Networks. This method imitates the way the human brain process information like a network of neurons thus the name Neural Networks.

The human brain manages information by forming paths for that certain information and thus 'learns' the information unlike LDA and the Minimum Distance which relies heavily on the features of the object. Examples and iterations develops or trains the network thus speeds up recognition. The framework of a Neural Network is shown below.


Figure 1. Neural Network Framework

A Neural Network is composed of three layers which are the input layer, hidden layer, and the output layer. The number of inputs in the input layer is determined by the number of features while the hidden layer can be composed of any desired number of nodes. The input receives the data/signals/features which in turn is forwarded to the hidden layer which acts on the inputs and finally passes the results to the output layer.

In this activity we feed the obtained features of our objects to a neural network composed of 3 input nodes that represent the 3 features used namely, area, perimeter and RGB sum. There are also 3 hidden nodes, and an output node. The learning rate used is 0.5 and the number of iterations is 1000.

To train the Neural Network we first entered into the network the training set and then followed by the test set. Figure 2 below shows the results obtained from the Neural Network. To implement this method, the code used by the previous AP186 class, made by Mr. Jeric Tugaff, was utilized. The classification showed 100% accuracy. Changing the order of the objects is also an interesting direction that can be took which might challenge the accuracy of the method since the Neural Network is not trained enough for recognition. I give myself a 10 for this activity.


Figure 2. Resulting classification obtained using Neural Networks.


Activity 15 | Probabilistic Classification

Previously we have performed object classification by using the Minimum Euclidean Distance of the obtained features of the train and test objects. Another method for classifying objects is the Linear Discriminant Analysis or LDA. This method simply uses the probability that an object belongs to a certain group which depends on the features of that specific object and the mean feature vector for that certain group. This also depends on the number of samples present in a group. The highest probability that an object belongs to a group automatically classifies that object into that group. This is called Bayes Rule. LDA uses this rule but starts by assuming the distribution of each group which a multivariate Normal Distribution and that all groups share the same covariance matrix. The probability that an object belongs to a group is given by,


where, is the mean of features for group i, is the feature data of object/row k in x which is the matrix containing the features data, C is the pooled within group covariance matrix, and p is the prior probability vector for object i. Simply, object k is assigned to group with highest f. The results for the data collected from last activity is shown below.



The yellow highlighted areas are the maximum f values. The test objects were also jumbled to show that the method works no matter what the order of test objects is. It can be seen that there is a 100% accuracy in the classification of the objects. I give myself a grade of 10 for this activity for successfully implementing LDA and getting a 100% accurate object classification.

References: Kardi Teknomo's Page - Discriminant Analysis Tutorial http://people.revoledu.com/kardi/tutorial/LDA/index.html