From morphological operations to cancer cells

Morphological operation is done on an image in order to change its shape and structure. Its concept is mainly based on set theory and topology. In this activity, we try to familiarize some basic operations and use them to measure size of “cancer cells”.

A good thing about these operations is that they are just a combination of two basic operations namely dilation and erosion.

To dilate the shape of “A” according to a structure element “B” is to add new elements near the edges of A with the help of B.

To erode the shape of “A” according to a structure element “B” is to remove elements near the edges of A with the help of B.

In a strict sense, these two are defined as the equations below.

eq1eq2

A very helpful video on how to implement these operations is shown by BleepTrack. We now try to implement these operations on a graphing paper.

 

Implementing Erosion and Dilation

Below shows how the shape subject A = 5×5 box, 4×3 triangle, 5×5 cross, and a 10×10 hollow box is dilated and eroded according to different structure elements B.

k1

(error above, will edit later)

k2

k3

k4

k5

It must be noted that these operations depend on both the shape of the structuring element and its origin (black point). Changing the origin while maintaining the shape of the structuring element would result to different morphology. It is only through experience and luck would one find the right structuring element to use.

We check our work with the result when we use Scilab to generate the shapes and to apply the operations. Below shows the similar results.

5×5 box

b1

b2

b3

b4

b5

4×3 triangle

t1

t2

t3

t4

t5

(error above again, will change later)

5×5 cross

c1

c2

c3

c4

c5

10×10 hollow box

h1

h2

h3

h4

h5

Other Morphological Operations

We now discuss other operations, which we have stated earlier, are just a combination of dilation and erosion.

Opening operation – This method is a combination of erosion followed by dilation using the same structuring element. For a binary image composed of 1’s and 0’s, what it does is to turn the 1’s into 0’s (in some sense “open” the 1’s). The points greatly affected are the 1’s near the edges. Refer to this tutorial for more examples.

Closing operation – This method is a combination dilation followed by erosion using the same structuring element. For a binary image composed of 1’s and 0’s, what it does is to turn the 0’s into 1’s (in some sense “close” the 0’s). The points greatly affected are the 0’s near the edges. Refer to this tutorial for more examples. (Thanks to Fisher et. al. for the tutorials).

 

Measure Size of Cells

The previous operations discussed can be used to segment (more on image segmentation here) cells from the background. Consider an image of cells below, prepared by Maam Jing.

The goal is to get a best estimate of the size of the normal cells using the image left image and use this to segment or differentiate the cancer cells (larger circles) with the normal cells in the right image.

Here are the main steps to measure size from the original image:

a. Divide whole image into multiple 256×256 images

b. Get histogram and segment by threshold

c. Slightly close openings in cells using Closing operation with a structure element of a circle of radius 1.

d. Clean image from isolated points and larger blobs (connected cells) using Opening operation with a structure element of a circle of radius 9

e. Use SearchBlobs() function to group blobs

f. Get area off all blobs from for all images and check histogram.

g. Calculate average size and standard deviation.

The following figures shows the results after doing the methods above. Left image is original image, center image is its histogram, and right image is the segmentation.

Although the cleaning of other artifacts (isolated pixels and holes in circles) was successful, there were many cells were the shape was distorted upon morphological operation.

Before calculating the mean and standard deviation, it is better to check first the histogram. Below (first image) shows the histogram for all the areas of the blobs. We observe some values greater than an area of 1000 pixels. Using this histogram to calculate the mean would be okay but not for the standard deviation since it would try to include the contribution of the larger blobs.

So we try to remove from the list all values with area > 1000. This threshold is more or less appropriate upon checking the peak (around 500) since more than twice the peak value means a blob of composed of multiple connected cells.

area-hist
histogram of all blobs

Upon applying the threshold, we get a better histogram shown below. We can now calculate its mean and standard deviation. The best estimate for the size of the normal cell is s=470 +/- 147 pixels.

area-hist1
histogram for small blobs

 

 

Differentiate Normal cells from Cancer cells

Using the cells with cancer image shown above, we try to segment the cancer cells using our knowledge in morphological transformations. Below shows the original gray scale image. Its histogram was taken and segment it using the threshold of TH=210.

Upon a closer inspection of the segmented image, we observe overlapping cells which can be problematic later on when we try to use the opening operation. These link on overlapping cells can be thinned using erosion. Below shows the results when erosion was applied to the segmented image with a structuring element of a circle with diameter of 3 pixels. Click on the images for a closer look on the effect.

We can now use the opening operation to segment blobs that more or less take shape of a normal cell. This means that other blobs that are composed of multiple cells or are eroded are removed. Below is the results of the opening operation using a structuring element of a circle of radius 12.

We can now use the best estimate size to select the cancer cells from the normal cells. This can be achieved using the function FilterBySize(). It selects the blobs based on an input size. The input size used was 470 + 147 = 617 pixels. The result is shown below.

The method shows to be successful in segmenting the cancer cells.

 

 

 

 

 

 

 

Advertisements

Author: klguial

undergraduate physics student

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s