Здравствуйте, friend.

In this activity we will tackle morphological operations using SciLab. Morphology is the study of the shapes or forms of anything. Therefore morphological operations change the shape of an object depending on what is needed. This activity will show how to use morphological operations in image processing.

We will now tell a tale of two operations namely, Dilation and Erosion.

Dilation adds new elements to an existing shape using a structuring element

Erosion deletes elements from an existing shape using a structuring element

The equation for these operations are:

ope

I think that it would better understood through an example

I will perform dilation and erosion to these shapes:

  1. a 5×5 square
  2. a triangle
  3. a cross
  4. a hollow box

with these structuring elements:

  1. 2×2 box
  2. 2×1 box
  3. 1×2 box
  4. 3 pixel wide cross
  5. a 2 pixel diagonal line

For Visualization:

These are the results of both Dilation and Erosion!

This slideshow requires JavaScript.

The green pixels denote the added elements while the red pixels denote the removed elements. These were made using the tools in this site: http://pixelartmaker.com/

It is important to note that the structuring element to be used for morphological operations are important such as its shape and parent pixel. different structuring elements create different morphological structures.

Now, we can actually check these using SciLab and the IPD module and these are my results. Note that I increased the hollow box to have a thickness of 2 pixels.

Dilation:

squaredilate

triangledilate

crossdilate

hollowdilate

Erosion:

squareerode

triangleerode

crosserode

hollowerode

In IPD there are more useful operations such as opening and closing operations. The only difference between these two operations is that an opening operation does a dilation then an erosion while the closing operation does the opposite. This will be evident in the edges of a shape.

Phew. okay now on to the next part of the activity.

We will use morphological operations in order to count cancer cells. The images to be used are provided by Dr. Soriano:

A difference between the two can clearly be seen. The image on the right has abnormally large cells. These cells have cancer. :(. It is quite easy to count now because there are only a few cells but imagine a whole days work in counting cells (much tamad to do). Using what we know about morphological operations we can actually count the cells easily.

Because size is what we compare here, we have to first measure the size of the normal cells. We have to divide the image on the left to smaller partitions then get the histogram to segment partitions as shown:

Segmented Image:

Threshold:

Fear not for I understand that some of the images are overlapping but it does not matter. A structuring element with size 9 is created using CreateStructureElement function of IPD  then i used the open opearation and I used the Searchblobs function and found the area for each blob. This is the Histogram of the area of the blobs:

area.JPG

The y-axis denotes the count of the blobs and the x-axis denotes the area of each blob. I took the liberty to discard values that are far from the main distribution because it will affect the calculation for the mean and standard deviation. The calculation of the mean and the standard deviation is important because this will be used in order to compare if a cell is “normal”.

Now, we will count the cancer cells in the second image provided using what we have gained from the previous part of the activity. Again the image is segmented.

tres

As you can see there are cells that overlap. If we were to calculate the area now we will be making a huge mistake because the overlapping cells will be treated as just one big cell. hence, we first have to use erosion I used a circular structuring element that has a radius of 2 pixels. The resulting image is shown below.

eroded.JPG

Now we use the opening operation again but using a structuring element of a circle with a radius of 12 pixels then take the area like the method earlier and filer by size. After doing all this the resulting image is shown with the cancer cells:

part1.png

Hooraaay!! Finally counted cells. We can further automate this by calculating for the centroid of each blob and finding the 1 values.