Wednesday, July 22, 2009

Acitivity 9: Binary Operations

In biomedical fields, cells from sample slides are classified through its size or area. For this purpose, image processing can be applied. In this activity, we were asked to estimate the area of a punched paper given an image.

Area estimation was done by first cutting the image into 256 x 256 subimages. To be able to get a more accurate estimated area, I decided to cut the image into 30 subimages since image cutting was programed in Scilab. After cutting the image, the next step was to convert the grayscale images (the original image was converted to grayscale first before cutting was done) into binary images. This was done by thresholding. A single treshold value was used for all the images since a uniform illumination throughout the original image was assumed. Here is one of the 30 subimages used.
After binarization..
As can be observed, the binarized image is not that "clean". To be able to "clean" it morphological operations must be used. Equipped with the knowledge of the previous activity, erosion and dilation are applied to the images. This was done by creating a opening function in Scilab. Opening can be described as the process of erotion followed by dilation. The structuring element used is a disk that is larger than the noise but must be smaller than the size of the punched papers.

The image above is the resulting image after applying opening into the binarized image. As can be observed the pepper noise found in the first binarized image is now gone. This is because in opening, the image is first eroded then afterward dilated. Since the size of the structuring element used is bigger than the noise and is smaller than the object, all objects with size smaller than the structuring element will be turned into background. The process was done for all the remaining 29 images.

The goal in this actiity is to estimate the area of a single blob, to be able to do this, the function bwlabel was used. The input of this fuction is a binary image and what it does is it labels an object(region of 1). Using this function, the area of each object in the 30 images were calculated through pixel count. The historgram of the areas calculated is given below.
From the histogram, the outliers can be easily distinguised. These outliers are the area of the blobs that are close to each other that they were seen as a single object, or the blobs that became smaller after opening was implemented. These outliers can be filtered. In this case, only areas ranging from 500 to 580 were considered.

From the filtered histogram, it was estimated that the area of a blob is 513.17 ± 23.33 pixels.

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

I thank Jica Monsanto for discussing with me this activity.

Activity 8: Morphological Operations

For this activity, we were able to explore different morphological operators and functions. Morphological operations were applied to five objects, namely: circle, square, hollow square, cross and triangle.

For the first part, the five images were eroded using four different structuring element. The first is a 4 X 4 ones, followed by 2 x 2 ones, 4 x 2 ones and lastly a cross that is 5 pixel long and a pixel thick.


SE = 4 x 4 ones

SE = 2 x 2 ones
SE = 4 x 2 onesSE = cross

The same objects were also dilated using the same structuring elements

SE = 4 x 4 ones

SE = 2 x 2 ones

SE = 4 x 2 onesSE = cross

As can be observed in the obtained dilated and eroded images, dilation pads-up the object depending on the dimensions of the structuring element used. On the contrary, erosion erodes the image as dictated by again the structuring element.

Before programming the erosion and dilation of the objects used, we were first asked to predict the results. Almost all of the predicted results for the dilation and erosion of images were the same as the results when programmed.

Other morphological operations like skel and thin were also explored.

The first column of the image above is the image original image, the second is the image after applying the function skel and lastly in the third column is the image after applying thin. The skel function skeletonizes the image. The thin function is also the same as the skel, however the method in which it thins the object is different to that of scale. As can be observed in the image above, the result of the skel is better than that of the thin function. Discontinuities are present in the thin function.

For this activity, I give myself a grade of 9 for I was able to do all the required tasks. However I was not able to fully discuss the process of morphology.

I thank Ms Herminia Balgos for discussing with me this activity.

Wednesday, July 15, 2009

Activity 7: Enhancement in the Frequency Domain

In this activity images are enhanced by filtering unwanted frequencies in the frequency domain.
For the first part of the activity, we were instructed to create symmetric dots and squares and obtain its Fourier transform. These were the images(left) and their corresponding Fourier transform(right) .


The Fourier transform of a point is a sinusoid. This is observed in the first pair of images where it can be seen that the image of the Fourier transform of the points looks like a mesh with varying intensity which is actually a sinusoid; and is only seen as that because the image is two dimensional.
On the other hand, the Fourier transform of two symmetric circles looks like an airy disk with a mesh inside. This is because the Fourier of the circles can be thought as the product of the Fourier transforms of two points and a circle. We know that the Fourier of a point is a sinusoid and that of a circle is an airy disk. Thus this resulted to the observed Fourier transform of the symmetric circles.
The same analogy applies for the square. The Fourier transform of the symmetric squares can be thought as the product of the Fouriers transforms of a square and two points. Again the Fourier of a point is a sinusoid and that of a square is a sinc. The product of the two will look like a sinc with a mesh of varying intensity inside. This is the observed Fourier transform of the symmteric squares.

It was also observed that as the radius of the circle and the sides of the square increases, the size of its corresponding Fourier transform decreases. This is the scaling property of the Fourier transform. Given a function, h = f(ax), its Fourier transfrom will be, H = (1/a)F(ax) [1].

Aside from circle and square, the Fourier transform of Gaussians were also observed for varying values of the variance.variance = 0.1variance = 0.4
variance = 0.8

Gaussian unlike other functions has a Fourier transform similar to a Gaussian. It is a self reciprocal function [2]. It can be observed that the obtained Fourier transforms looks like a gaussian with a mesh inside. The explanation for this is similar to what was discussed earlier. The Fourier transform of two symmetric gaussians can be thought as the product of the Fourier transfor of a gaussian and two points. Thus this will result to the image obtained.

Similar to what was observed earlier for the circle and square, increasing the variance of the gaussian results to the decrease in the size its Fourier transform. This is due to the scaling property of the Fourier transform.

After familiarizing ourselves with different Fourier transform, we then enhanced images by filtering unwanted frequencies in its Fourier transform. This was first done with the image of a fingerprint as shown below.Taking the Fourier transform of this image will result to the image below.

The Fourier transform of the image contains frequencies of the image. Blocking unwanted frequencies will result to an image absent of the unwanted details corresponding to the blocked frequencies. With this in mind a filter was created using gimp.

Multiplying this filter to the Fourier transform of the image will block unwanted frequencies and will result to the image below.

As can be observed, other details like the text "CO" and "09" and "INDEX" were omitted from the filtered image.

Using the same principle, the process was applied to another image below.

Its Fourier transform is the image below.

This is the masked used to block unwanted frequencies.

After getting the inverse Fourier of the product of the Fourier transform of the image and its mask..
As can be observed the lines present in the original image are not visible in the filtered image. Also notice the mask used to block the unwanted frequencies. It can be noticed that the mask looks like the Fourier transform of a sinusoid with different frequencies. This is because the lines present in the original image can be thought as sinusoids.

The same process was used for an oil painting in Vargas Museum. Since the oil painting was painted in a canvas, one can actually separate the painting itself from the canvas using frequency filtering. The painting is the picture below. The Fourier transform of the image is..


To create a filter mask removing the canvas weaves, we must first think what should the Fourier transform of the canvas weave look like. Based from the knowledge from the previous exercise we have an idea that the Fourier transform of the canvas will look like the Fourier transform of several sinusoids with different frequencies. Thus the filter will look like...
The resulting filtered image will then be...

As can be observed the brush strokes are more enhanced than the canvas weaves. Similarly, we can invert the filter used to mask the canvas weave so that we will be able to simulate the appearance of the canvas weave.


As can be observed, the simulated canvas weave thus looks like the canvas weave of the painting.

I would like to acknowledge Irene Crisologo for teaching me how to create a filter in Gimp.

for this activity I will give myself a grade of 10 for I was able to do and enjoy all the requirements for this activity.

References:

[1]http://en.wikipedia.org/wiki/Fourier_transform
[2]http://cnyack.homestead.com/files/afourtr/ftgauss.htm
[3]Activity 7: Enhancement in the Frequency Domain Manual

Wednesday, July 8, 2009

Activity 6. Properties of the 2D Fourier Transform

Disclaimer: partially done.

6.A Familiarization with FT of different 2D patterns

For this part of the activity the Fourier transform of the different patterns: square, square annulus, annulus (doughnut), Two slits along x-axis symmetric about the center and two dots along x-axis symmetric about the center were simulated.


Two-slits

square

two dots

square annulus

annulus(doughnut)

B Anamorphic property of the Fourier Transform

For this part of the activity a 2D sinusoid was generated. Similar to the previous part of the activity, its Fourier transform was calculated.The Fourier transform of a sinusoid is a dirac delta peaking at both positive and negative values of its frequency. The sinusoid generated is along the x axis with frequency equal to 4. Thus its resulting Fourier transform is an image peaking at two point (which I think is 4 and -4).

The Fourier transform of a sinusoid with a constant bias was also observed.bias = 0.1, frequency = 4


bias = 0.5, frequency = 4
bias = 2, frequency = 4

Adding a constant bias in the sinusoids results to a peak in the origin in the frequency space of the Fourier transformed image. As can be seen from the images above, the Fourier transform of the images for a sinusoid with frequency of 4 and bias equal to 0.1,0.5 and 2 have peaks at the origin. It can be noticed that at values much less than 1, the peak found at the origin has a lesser intensity compared to the peaks found at the value of the frequencies. And as the value of the bias increases (greater than 1), the intensity at the origin becomes greater than the value of the frequencies. This is because the range of values of sine is from -1 to 1 only. Hence, biases at this range does not exceed the peak of the frequency values. However, biases out of this range has a peak higher than the frequency values.

When the generated sinsusoids were rotated by a desired angle, the resulting Fourier transfrom were the following:
frequency = 4, angle = 0 degreesfrequency = 4, angle = 45 degrees

frequency = 9, angle = 90 degrees

When the sinusoid was rotated by an angle, the resulting Fourier transformed was also rotated by the same angle. The images abve shows sinusoids of frequency 4 and 9 with angle of rotation equal to 0, 45 and 90 degrees.

When the combination of two sinusoids was Fourier transformed, the resulting image is the following:
frequency = 4

The Fourier transform of the new sinusoid which is the product of two sinusoids (corrugated roof) running in the x and y direction shows the frequencies present in the product.

When several sinusoids are added to the previous sinusoid shown above the resulting image and its Fourier transfrom is found to be..


frequency = 4 at angles 30, 90, 120 and 330 and previously generated sinusoid

The Fourier transform of the image is the same as my predicted result. One property of Fourier transform is linearity. It means that given a function h which is expressed by f and g and its corresponding Fourier transform H, F and G, the Fourier of h is given by..

h = f + g
H = F + G

Because of this property of Fourier transform the image of the generated sinusoid above will just be sum of the Fourier of the previously generated sinusoid which is the corrugated roof, and the sinusoids with frequency equal to 4 rotated at angles 30, 90, 120 and 330 degrees.

I give myself a grade of 10 since Iwas able to do all the required tasks and I was able to observe and understand the properties of Fourier transform.