Wednesday, September 22, 2010

Entry 16: Binary Operations

Ola!  In this activity, we performed binary operations to identify simulated normal cells and discriminate cancer cells from normal cells.  We implemented our knowledge of morphological operations to achieve our goal.

We performed the method of classifying the normal cell area by first taking patches of 256x256 pixels from the original image.  This process was implemented by randomly taking a point from the original image and acquire the patch starting at that point, this way, the bias was reduced.  Samples from the randomly chosen patches are shown in Fig. 1 along with the binarized version with the threshold equal 0.84.

Figure 1: Sample of the 256x256 patches from the original image and their corresponding binarized versions.
The binarized version was done by choosing a threshold based from the pixel value histogram as shown in Fig. 2,

Figure 2:  Pixel value histogram of a sample patch indicating that the threshold is near the value of 0.85.
After generating the binarized patches, we identified the distribution of area of contiguous regions using the function bwlabel().  The histogram of the contiguous regions from the entire subimages are shown in Fig. 3.  It must be noted that we limited the reasonable area to be counted in the histogram in the range 50px to 1000px only.  Values outside the specified range are assigned to be outliers.

Figure 3:  Histogram of the area of contiguous regions in the patches.
In Fig. 3, we observed that the most probable area is about 500px.  Thus we conclude that a normal cell has a mean area of 500px.

Now, we find a method to identify a cancer cell in a region with normal cells.  We utilized the computed area of a normal cell and used it in the discrimination method.  We know that when a region of smaller area is applied with the open morphological operation with a structuring element with a larger area, the region will vanish.  Since the the cancer cells are relatively larger, it is possible to remove the normal cells by opening the image with the structuring element with area equal to the normal cell.

After applying the method, we have successfully determined the cancer cells from the rest of the normal cells as shown in Fig. 4.

Figure 5:  Image of normal cells with randomly located cancer cells.  Also shown are the detected cancer cells.
Based from the results, we have verified the application of binary operations in identifying cancer cells in an ensemble of normal cells.

In this activity I developed a better grasp of the concept of morphological operations and I learned that extensive applications may be adapted using the basic morphological operations in binarized images.  I'll be rating myself 10/10 because I completed all the requirements for this activity and also because of the knowledge I gained.

Source:
    Activity Sheet for Activity 10 - Dr. Maricor Soriano
    Thanks to BA Racoma for giving me a tip regarding the open operation. :D

Tuesday, September 21, 2010

Entry 15: Morphological Operations

Morphological operations are methods in transforming an image by using a specific structuring element to yield desired formation in the image.  This technique is widely used in image processing to produce a more easy-to-handle image.

Two main morphological operations are used in this activity which are the dilate and the erode operations.

The erode operation is defined mathematically as,


this means that every points in B must be contained in A so that the value in A where the origin of B is located will attain a value, else, a zero value will be assigned to that B location.

Graphically it can be illustrated by the image below.


The dilate operation on the other hand is defined mathematically as,


the implication of this equation is that when B covers a location in the background, provided that the origin of B is contained in A, then the background region covered by B will take the value of the foreground.

An illustration is shown by the image below.



Below (Fig. 1) are the images to be structured and (Fig. 2) are the structuring elements used.

Figure 1:  Images to be structured.

Figure 2:  Structuring elements used in the process.

In the succeeding images, we show the results of dilating the original images (Fig. 1) with the strels (Fig. 2).

Figure 3:  Dilated images using a 1x2 strel.

Figure 4:  Dilated images using a decreasing diagonal strel.

Figure 5:  Dilated images using a 2x1 strel.

Figure 6:  Dilated images using an increasing diagonal strel.

Figure 7:  Dilated images using a 2x2 strel.
Figure 8:  Dilated images using a cross strel.

After determining the dilated images, we tried another morphological operation which is erosion.  The images below are the eroded original (Fig. 1) images using the strels in Fig. 2.


Figure 9:  Eroded images using a 1x2 strel.

Figure 10:  Eroded images using a decreasing diagonal strel.

Figure 11:  Eroded images using a 2x1 strel.

Figure 12:  Eroded images using an increasing diagonal strel.

Figure 13:  Eroded images using a 2x2 strel.

Figure 14:  Eroded images using a cross strel.
Morphological operations can be applied to different image processing problems to simplify them.  The usefulness of these operations depend on the user.

In this activity I would rate myself a grade of 10/10.

Source:
    Activity Sheet for Activity 9 - Dr. Maricor Soriano



Entry 14: Enhancement in the Frequency Domain

Speaker: Fourier transform enables us to travel across dimensions!  

Audience: How?!!!

Speaker: It's because Fourier transform empowers us to see the world of the inverse dimensions!

Audience: Ok...


This activity emphasizes the power of Fourier Transform (FT) in various applications.  To be discussed here are the simple exercises made to get a better idea on how FT changes some properties of our object.  Also, a major application of FT will be included here which is about using FT in cleaning digital finger print images.  The application of FT in filtering repetitive patterns of "noise" in painting due to its canvas weave and removal of vertical lines in a photograph was used to correct these issues and to produce a better image.

So we first simulated the action of FT on basic patterns as shown in the FT pairs below (Fig. 1).

FIgure 1:  Fourier Transform pair of different basic patterns (symmetric dots, symmetric circles and symmetric squares).

Also the FT pair of the Gaussian pattern was simulated.

In the next section, we performed enhancement of a fingerprint image using filtering techniques in the Fourier space of the image.  The image of the fingerprint is shown in Fig. 2,

Figure 2:  Original image of the fingerprint to be "cleaned".

To start filtering, we first identify how the frequency world of the fingerprint image look like so that we can identify the proper filtering mask to use to discriminate unwanted information in the image.

In Fig. 3, the FT of the fingerprint image is shown which reveals the nature of the frequency of the information in the image.

Figure 3:  Fourier Transform of the fingerprint image which shows the frequency component of the image.

We realize based from the information from Fig. 3 that the frequency of the information relevant to the fingerprint is not well distinguishable from the noise so we chose a smoothing mask to use to smoothen the noise in the image and from that smoothened image, we can do thresholding to determine the actual fingerprint image discriminating the noise.

We show in Fig. 4 the mask used to filter the fingerprint image.  The mask is composed of two Gaussian functions, one with a very small variance to facilitate the filtering of the DC component and the other Gaussian filter is responsible to discriminating the noise of high frequencies.

Figure 4:  Double Gaussian filter to clean the fingerprint image.  Sigma used are 0.0001 and 18 to filter the DC and high frequency components of the noise.

After applying the filter to the original fingerprint image, we now have the smoothened/filtered version.  The result is shown in Fig. 5.

Figure 5:  Left) Filtered image using the double Gaussian filter, Right) Thresholded filtered image showing the significant details of the fingerprint showing that the noise were wiped out.

Also shown in Fig. 5 is the final filtered image of the fingerprint.  After taking the smoothened image, we applied thresholding to it to wipe away any traces of noise in the background to only leave the significant components constituting the fingerprint.

The next task is to remove vertical artifacts from one of the images of the moon's surface (Fig. 6).  It was said in the image details that the artifact was due to the concatenation of individual framelets to make the entire image [1].

Figure 6:  Original image of the moon's surface with evident vertical lines.

To start the process of filtering the vertical lines in the image, we first converted the image into a grayscale version and took the FT of it to reveal the frequency values in the image (Fig. 7 - Left).

Figure 7:  Left) Fourier Transform of the grayscaled moon image showing repetitive dots along the x-axis, Right) Filtering mask used to remove the vertical lines.

From our Activity 7, we learned that the FT of vertical lines correspond to a series of dots in the x-axis of the frequency space.  Thus we made a filtering object that masks the points where the information relating to the vertical lines were located (Fig. 7 - Right).

After applying the mask to the image's FT and going back to the linear domain, we produce the filtered form of the image.  In Fig. 8, shown are the original image along with the filtered image of the moon.

Figure 8:  Left) Original grayscale image of the moon with evident vertical lines, Right) Filtered image wherein the vertical lines were removed.

Lastly, we performed the same method to a painting.  The task is to remove the effect of the canvas weave on the image.  The original image is shown in Fig. 9.

Figure 9:  Original image of the painting with very obvious canvas weave pattern.

We get the grascale of the image of the painting and took the FT of it to reveal the localized high valued frequencies.  Localized high valued frequencies can be thought to carry the information of the frequently occurring canvass weave pattern and there we based the mask to be used for filtering.  The FT of the image and the mask is shown in Fig. 10.

Figure 10:  Left) FT of the painting image showing localized high valued frequency, Right) Mask developed to filter the canvass weave pattern.

After applying the mask to the FT of the image and returning back to the linear domain, we get the filtered image wherein the canvass weave pattern can no longer be seen.  In Fig. 11, shown side by side are the original grayscaled image of the painting along with the filtered image.

Figure 11:  Left) Original grayscaled image of the painting, Right) Filtered painting showing no signs of the canvass weave pattern.

The last thing we did in this activity is to show the image of the mask used in linear domain.  We can see in Fig. 12 the similarity of the linear domain version of the mask used to the canvass weave pattern.

Figure 12:  Linear domain version of the mask used in the filtering of the painting.

In this activity I would give myself a 10/10 for the dedication and the learning I had during this activity.

Source:
    [1]  Activity Sheet for Activity 8 - Dr. Maricor Soriano