In image processing, especially if one is dealing with a region of interest (ROI) in an image, it is necessary to separate the ROI from the background. Thresholding is one way to effectively separate the two. This will reduce the image into a binary one. However, this requires an optimum threshold but this optimum threshold does not guarantee us a perfect separation of the ROI and the background. Instances that would sacrifice some of the ROI to zero out the background and vise-versa may be encountered. Hence, a threshold somewhere in between must be chosen that would leave some white pixels in the background and holes on the ROI.
In such cases (which happens more often), morphological operations must be performed for two basic reasons: (1) to remove the small white pixels on the background and holes on the ROI and (2) to separate touching blobs in the image. Blob separation is very important for accurate determination of cell sizes, etc. Here,we use the closing and opening operators to serve our purpose. Closing is just a dilation of the image followed by an erosion. Opening is the opposite.
Using the image below, we segment this into 256x256 sub-images. Threshold is applied to binarize each sub-image. Morphological operations is then performed per binarized sub-image. The area of each blob (in pixels) is calculated per sub-image. A histogram of blob areas is then obtained from all the sub-images. The thresholded is shown in Fig.2.
Before the process of opening and closing, choice of the structuring element (SE) is needed. In choosing, we have to take into account that the SE should not be large enough that upon dilation will not cause originally separated blobs to connect. As such, performing an erosion operation will not be able to separate them again. If, on the other hand, the SE is small enough, closure of relatively large holes will not be effective. Even repetitive closing would be futile. A balance between the two must be chosen.
Here, a 3x3 cross was chosen as the SE, since there are no large holes in the binary images obtained. One of the advantage of this SE is that this will not join blobs upon closing thus we can accurately determine the cell sizes.
Here, a 3x3 cross was chosen as the SE, since there are no large holes in the binary images obtained. One of the advantage of this SE is that this will not join blobs upon closing thus we can accurately determine the cell sizes.
Using thus SE, we perform three opening to effectively remove the white pixels in the background and one closing to close the holes in the ROI. Then we use the bwlabel to label the blobs in each sub-image and calculate their areas in pixels. A figure below shows all the blobs obtained from all sub-images. Each blob are shaded differently.
From the areas computed, we plot the its histogram to approximate the sizes of the cells. In Fig.4, we can see that most blobs are composed only of one cell. Judging from this, we can pretty much predict that the peak of the histogram would occur at area of single-cell blobs. Below is the histogram obtained.
Figure 5. Histogram of areas in pixels
The peak corresponds to the approximate size of the cells. Examining Fig.5, we can infer that the cell size is approximately 550 pixels.
In this activity, I give myself a grade of 10 for doing the job well. I acknowledge Orly, Mark Jayson and Thirdy for useful discussions and laughter.
In this activity, I give myself a grade of 10 for doing the job well. I acknowledge Orly, Mark Jayson and Thirdy for useful discussions and laughter.
No comments:
Post a Comment