Monday, September 3, 2012

Act 10. Feeling like a robot? Morphological operations 3/3: Looping through images

Our objective for this week is to be able to perform a simple task - specifically tagging objects with irregular features - and automating it for multiple pictures.

The given simple task is to isolate the bigger circles from this picture. This is similar to the detection of possible cancer cells in a sample of normal cells.

Punched out circles with a few larger circles mixed in.
The first step to figuring out which ones are irregular is to create a standard for regular cells using this picture which has no "cancer cells".

Calibration picture

To make it easier to process, we first transform it to a black and white image. Looking at its histogram, it's easy to choose 0.85 to separate the blacks and whites.
(left) histogram             (right) black and white image
Using the same command as the ones used in the singing scilab activity,
[L, n] = bwlabel(image); 
and by imshow-ing L, we can visually see which dots are connected(they have the same exact color).
Original picture with each blob tagged with a different integer
Connected blobs present a problem, as the only difference between "cancer cells" and "normal cells" is their area. Looking at the histogram of blob sizes, 

(code for blob size)

Blob sizes histogram
A lot of particles have blob sizes of roughly 500, so we can hypothesize that the circles have radii of around 12 pixels.

Going back to the cancerous image, I eroded it with a circles of radius 10... and the cancerous cells were successfully identified!

(left) eroded image (right) tagged cells

Yeah, so I'd consider that a success. :D The advantage of the method I employed is that it would be able to identify the big circles even if they touch the smaller circles.

The only bad thing was, it took a couple of seconds of my laptop sounding like a fan to produce this result. The load on the machine can be reduced by processing smaller segments at a time.

I automated the cutting of the original image.

Then, looping through the second element of dir(filepath of pictures), the identification was done automatically. :)

I'd give myself a grade of 9 for not working entirely on the cut-up images.



No comments:

Post a Comment