Tuesday, August 20, 2013

Application of Binary Operations

In this activity, we try to identify the areas of blobs in an image and locate which of them are "abnormal", based on the mean and the standard deviation of the areas. This method is important in biomedical imaging, particularly in identifying cancer cells.

Our sample image, Figure 1, contains numerous circular shapes with uniform areas. With visual inspection, we identify the abnormal cells to be the ones enclosed with a red rectangular shape in Figure 2.
Figure 1. Collection of "cells" with randomly placed "cancer cells"

Figure 2. Identified "cancer cells"

Before we can locate these cancer cells, we first need to "calibrate" our detecting system using a set of normal cells. We were given the following image as a basis for measuring the mean area of the cells:

Figure 3. Collection of "normal cells" for calibration

This image was split into smaller images, and each of them were converted to black and white.
Figure 4. Conversion of image segment to black and white.

Reducing the image to black and white produces an image with random white spots, which are part of the background but are above the threshold value set using the function im2bw(). Since it would be difficult to determine the exact value for the threshold in order to eliminate the noise, we need to have a system that would remove these spots. Morphological operations will allow removal of these random spots by locating the shapes of specific sizes and shapes and retaining only those that will satisfy the structuring element. The function OpenImage(im, se) of Scilab performs an erosion of the image im using the the structuring element se. Afterwards, it performs a dilation on the image using the same structuring element. The function CloseImage(), also a morphological operation, is similar to OpenImage(), but instead performs dilation before erosion.

Using the function CreateStructureElement(), I created a circular structuring element with a dimension of 11x11 pixels. With OpenImage(), the spots were removed:

Figure 5. Noise reduction using OpenImage()

You would also notice that the cells on the image at the right portion of Figure 5 have different gray levels. The cells were labeled using the function SearchBlobs(), which identifies continuous portions on the image. The clump of cells at the right-center only has 1 value for the gray level, meaning the function identifies it as a single cell. This would cause problems later in the process of measuring the mean area of the cells. 

Performing these operations on all the subimages, I now have the following: 

Figure 6. Noise reduction for all the subimages

Figure 7 below shows that we can isolate each blob. From these segments, we can have a measure of the area of the cell, which is simply the number of pixels having 1 as a value.

Figure 7. Isolation of different blobs

Using histplot(), I obtained a histogram of the measurements of the area for all the blobs.
Figure 8. Histogram of the area measurements

There are extreme values for the area with low frequencies, all located beyond the 1000-pixel mark. These measurements arise from the cells that overlap each other and formed a large blob. We neglect these values since they are obviously not the values that we need to approximate for the cell sizes. Selecting only the values for area below 900 pixels and above 300 pixels. The latter criterion was imposed because there are cells located at the boundaries of the image, which constitute the distribution at the left end of the histogram. Using these values, the cell size was found to be 507.23 pixels with a standard deviation of 90.44 pixels.

With these measurements, I was able to locate the cancer cells from the given image:
Figure 9. Identified cancer cells

There was an additional trick however, aside from using the mean and standard deviation values for the area. After I have located the blobs with areas outside the acceptable values, I performed another OpenImage() step, but with a much larger structure element. I used a circular structure element with a radius of 15 pixels. Without this step, the program will retain the blobs that represent overlapping cells, which actually have areas larger than the acceptable value. However, as mentioned previously, these are not the cells that we want to locate. With this, we now only have the cancer cells.

For this activity, I'll be giving myself a grade of 10/10 for accomplishing the activity properly.

Reference
A11 - Application of Binary Operations: Blob Analysis activity manual. M Soriano. 2013.





Sunday, August 11, 2013

Enhancement in the Frequency Domain

In this activity, our goal is to eliminate unwanted information in an image by manipulating in the frequency domain. But first, we investigate what the frequency domain looks like for different types of images. 

Two dots (1x1 pixel each) was placed equidistant from the center of the 128x128 pixel image. These dots represent a pair of Dirac deltas, which is the Fourier transform of the sine function. The spacing between the two Dirac deltas is twice the frequency of the sine function. Using fft2() on the images containing two Dirac deltas (images at the upper part of Figure 1) produces a matrix containing the inverse Fourier transform. That is why the images at the lower part of the same figure show sine functions of increasing frequency (smaller gap between successive bands) as the spacing between the Dirac deltas is increased.

Figure 1. Pair of Dirac deltas and corresponding inverse Fourier transforms.

In the fo