Wednesday, September 23, 2009

Activity 18: Noise Models and Basic Image Restoration

In reality the images that we are able to capture does not exactly replicate the object of our desire. Often than not, the images that we capture contains noise that can be due to the environment or background while acquiring the images, the object itself or even the imaging device that we use.

In this activity we played with different noise: exponential, gamma, gaussian, rayleigh, salt and pepper and uniform noise. These noises were added to an image. Same as adding noise to the image, we tried to restore the original image using four image restoration techniques - arithmetic, contraharmonic, geometric and harmonic.

Noise is composed of random variables that are characterized by a probability distribution function or PDF [1]. The PDF of exponential, gamma, gaussian, rayleigh, salt and pepper and uniform noise are given in the following equations.

For Exponential noise, it's PDF is expressed by,

where the mean and variance are given by,
The PDF of Gamma noise is given by,
where the mean and variance are given by
The PDF of Gaussian noise is given by,
where µ is the mean value of z and σ is its standard deviation. Meanwhile the PDF of the salt and pepper noise is given by,
The PDF of the Rayleigh noise is expressed by the following equation,
where the mean and variance are given by,
The PDF of Uniform noise is given by,
where the mean and variance are given by,
These six noise were generated and added to the image shown below.

Its histogram is given by,

The addition of the six different noise to the image above are shown in the following image.

GENERATED IMAGE WITH NOISE
clockwise direction: exponential noise, gamma noise, gaussian noise, rayleigh noise, salt and pepper noise, uniform noise.

HISTOGRAM OF GENERATED IMAGE WITH NOISE
clockwise direction: exponential noise, gamma noise, gaussian noise, rayleigh noise, salt and pepper noise, uniform noise.

The generated images with noise were restored using four image restoration techniques - aritmetic filtering, contraharmonic filtering, geometric filtering and harmonic filtering. Given that the corrupted version of an image is described by g(x, y), a retangular window of size m x n centered can be defined such that this window g(s, t) is centered at point (x, y) . Following this, the arithmetic mean filter is given by the following equation,

On the other hand geometric mean filter is given by,The harmonic mean filter is given by,The contaharmonic mean filter is given by,where Q is called the order of the filter. For positive values of Q, the filter pepper noise. On the other hand for negative values of Q, salt noise are eliminated.

The four filters described above were applied to the images with noise described above. The results are shown below.

row(top to bottom): exponential noise, gamma noise, gaussian noise, rayleigh noise, salt and pepper noise, uniform noise.
column(left to right): type of noise, arithmetic filter, contraharmonic filter (Q = 1), geometric filter, harmonic filter


It can be observed that indeed for Q = 1, the contraharmonic mean filter eliminates pepper noise. For Q = -1, the result of applying this filter to an image with salt and pepper noise is shown in the following image.

Observe that since a negative value for Q was used, the resulting image has no pepper noise. However it can be observed that the image has more pepper noise than the previously noisy image. It seems like part of the image with salt noise were converted into pepper noise. This is also observed to the image of the restored image when Q is positive. However instead of having several pepper noise, the image is full of salt noise.

The same process was applied to a different grayscale image.

image taken from: http://incisors.files.wordpress.com/2008/06/gs.jpg

when noise was added to this image,

IMAGE WITH NOISE
clockwise direction: exponential noise, gamma noise, gaussian noise, rayleigh noise, salt and pepper noise, uniform noise.

Applying the filters resulted to the following,

row(top to bottom): exponential noise, gamma noise, gaussian noise, rayleigh noise, salt and pepper noise, uniform noise.
column(left to right): type of noise, arithmetic filter, contraharmonic filter (Q = 1), geometric filter, harmonic filter

Comparing values of Q (positive and negative) for the contraharmonic filter,

(left-right): Q = 1, Q = -1.

Again it can be observed that at positive values of Q, pepper noise is filtered out from the image and at negative value of Q, salt noise is filtered out.


For this activity I'll give myself a grade of 10 for I was able to do all the required tasks.

I thank Jica Monsanto, Irene Crisologo, Thirdy Buno and Janno Vergara.


References:
[1] Activity 18: Noise Models and Basic Image Restoration Manual

Wednesday, September 9, 2009

Acitivity 17: Photometric Stereo

3D imagery is of increasing importance in many fields such as biomedicine and computer vision. There are different ways of obtaining the 3D reconstruction of an object. Some of these are stereo vision, structured illumination, 3D from motion and photometric stereo. In photometric stereo, depth is calculated from shadow cues. This is done by capturing images of the objects with the source at different locations. Let V be the matrix describing the x, y and z component of the light source and I be the matrix containing the images of the object at different light source location. The relationship between the source location and a specific location at the surface of the object as seen by the camera is given by,

I = Vg

g can be solved using the least square method and is given by,

Using g, the normal vector can be calculated by normalizing g. Once the surface normals are estimated, they are related to the surface elevation or the depth z which is here expressed as the function f,
The depth z is at a point (u,v) in th image of the object is evaluated by a line integral given by,


In this activity, the 3D reconstruction of a sphere was rendered. This was done by capturing images of the sphere at different light source locations. The following figure shows the images of the sphere used.Using the equations discussed earlier, the surface normals of the sphere were calculated. The depth z of the object was then calculated and visualized using the plot3d function in Scilab. The obtained reconstruction is shown below.
As can be observe, the reconstruction resembles a sphere. However, it can be observed that there are visible grooves.

For this activity I give myself a grade of 9. Although I was able to reconstruct the sphere, still I fail to explain the reason for the visible grooves.

I thank Jica Monsanto and Irene Crisologo for useful discussions.


References:
[1] Acitivity 17: Photometric Stereo Manual