Wednesday, October 1, 2014

AP 186 Activity 8 - Morphological operations part 2

Now we will use the applications of what we did in the post of Morphological operations part 1.

So we take an image of punched circles which are scanned in a flatbed scanner.


Now, I have to divide this images into 256x256 pixel subimages, with their filename in an increasing number, I named them C_01.jpg and so on. The first subimage is shown:


Now we made a histogram of this image so that we will know its threshold. Knowing this threshold will help us segment the image. The histogram is shown below.
And the threshold that I got is 211.83, and I used this value to SegmentByThreshold() function in Scilab. This is the result:

Now we have to clean the image, and we have three choices of morphological operators: CloseImage, OpenImage, and TopHat that are available in the IPD toolbox. I chose OpenImage and it is defined as "This function applies a morphological opening filter to an image. This filter retains dark objects and removes light objects the structuring element does not fit in. " which is suitable for the image. Now we need a structuring element and I used CreateStructureElement() function of a circle of size 11. The cleaned image is now:

Next we have to remove those circles which are overlapped. To do that we have to label each contiguous blob using SearchBlobs. Each connected blob will be replaced with a number. Then I have to filter them by size. We don't know what the sizes are so what I did was I marked all blobs per subimage then plotted the histogram of the sizes of the blobs from all the subimages.

From the histogram, I ignored the zero interval then chose the interval where it peaks. I chose the interval from 400 to 550 since that is where the peaks are. I used this interval to FilterBySize() function to separate the circles/cells which are overlapped. Then, I used a colormap to distinguish them uniquely by color.

I used these steps for all the subimages. I calculated the mean for each subimage and averaged these mean values. The standard deviation of the means was calculated from the averaged mean values.

Averaged mean: 532.10606
Standard deviation: 107.15587 

The standard deviation is used as the uncertainty and so the limits I will use for the size of a normal cell will be 532.10606 ± 107.15587 pixel area.

So now we proceed to isolate the abnormal sized cells using the knowledge of the best value of size of normal cell. We have an image of normal cells with cancer cells:
We have to use the steps I enumerated earlier:

1) Segment the image to emphasize cells.
2) Use morphological operation OpenImage() to clean the image with structuring element circle of size 13 since the SE earlier gives out overlapped blobs even after filtering it.
3) Uniquely mark the blobs. 
4) Use FilterBySize function to filter out overlapped cells. 

We will use the pixel area obtained from the subimages part. We will use the 532.10606 + 107.15587 pixel value as the lower limit of FilterBySize. This will store the blobs/cells with area higher than 532.10606 + 107.15587. It will not store the blobs lower than this value.

Here is the filtered circles with cancer image that are marked. 

Then, the inverted filtered image was convoluted with the original cancer image so that it will output an image that looks like the original image but is marked. The result is shown below:

The abnormal/cancer cells are marked and you can see that they are really bigger than the others.

I give myself a score of 10/10 since I completed this activity and did all that is required.

I had a difficult time with the cancer cells because it was not displaying the output I wanted. I had to change the structuring element so that it will not display the overlapped circles.

References:
[1] M. Soriano, AP 186 manual, A8 - Morphological operations, 2014.



No comments:

Post a Comment