Binary Operations

Binarizing an image at an optimum threshold enables us to separate the background from the region of interest (ROI). However, when there is an overlap in the graylevel distribution of background and ROI, the binarized image may need to be further cleaned by morphological operations. Examples of such operations are opening and closing. The closing operation is dilation followed by erosion of the same structuring element whereas the opening operation is the reverse. This activity aims to integrate these operations and other image processing techniques to determine the best estimate of the area in pixel count of simulated cells.

Area estimation of normal cells

Figure 1. An image of scattered punched paper under a flatbed scanner. Imagine these circles as "normal cells" under a microscope.

As a start, the image above was cut into seven subimages of dimensions 256×256. The grayscale histogram of each subimage was examined to find the optimum threshold for its binarization, such that the noise in the background is minimal. For each of these subimages, the closing and opening operators were applied using circle structuring elements to close off the holes and remove background noise respectively.

Figure 2. (a) Original subimage (b) Binarized subimage at optimum threshold (c) Cleaned subimage after application of morphological operations.

bwlabel was used to label each contiguous blob on the binarized image and measure for their area in pixel count. These are implemented in Scilab as follows.

count = 1;
for i=1:7
  I = gray_imread("C_0"+string(i)+".jpg");
  im = im2bw(I,0.85);
  im = dilate(im,SEclose,[13,13]);  //closing
  im = erode(im,SEclose,[13,13]);
  im = erode(im,SEopen,[13,13]);    //opening
  im = dilate(im,SEopen,[13,13]);
  [L,n] = bwlabel(im);
  for j=1:n
    blob = (L==j);
    area(count) = sum(blob);
    count = count + 1;
  end
end

The areas of the blobs measured for all subimages were tallied to find the range of the most detected areas.

histplot(length(area),area);

Figure 3. Histogram of the areas detected for all cleaned subimages.

Zooming in this histogram, the most detected areas fall under the range of 490 to 600. We now calculate for the average area of cells in this range.

values = find(area>490 & area<600);
R = area(values);
Area = mean(R);
SDev = stdev(R);

Results:
Average area: 517.80769
Standard deviation: 12.515652

To verify the result, the area of a single cell was computed giving us a value of 526.

Isolation of cancer cells

Now consider the image of punched papers wherein some cells are larger than the rest. The goal is to isolate cancer cells represented by the enlarged cells.

Figure 4. Another set of digitized punched papers with some cells bigger than the rest.

Since we have already computed for the range of values for the average size of the normal cells, we can now isolate the enlarged cells by applying the opening operator using a structuring element slightly larger than the normal cells. The following is the resulting image, wherein all five cancer cells were isolated.

Figure 5. Isolated abnormal cells after application of opening operator.

For this activity, I give myself a score of 10/10.

Leave a comment

Design a site like this with WordPress.com
Get started