Hi Quinten,
It is my understanding that you have an image of an oocyte cell, on which you are applying the “otsu thresholding” method to obtain a binary image of the cell, However due to high variation in pixel intensity inside the cell, the method fails and detects it only partially. Hence, you want to know a robust method to detect the cell as a whole.
Follow the below pointers to postprocess the mask to detect the cell as a whole:
- Apply the dilation morphological transformations on the inverted binary mask obtained after “otsu thresholding”.
- Suppress the light structure connected to image border using the “imclearborder” function.
- Fill image region and holes using the “imfill” function.
- To further improve the cell detection, detect the largest white connected component and create a mask for it. Use the “bwlabel” and “regionprops” function for this purpose.
Refer to the following code snippet to postprocess the mask to detect the cell as a whole:
image = imread('PathToImgFile');
grayImage = rgb2gray(image);
threshold = graythresh(grayImage);
binaryImage = imbinarize(grayImage, threshold);
binaryImage=~binaryImage;
binaryImage = imdilate(binaryImage, se);
binaryImage = imclearborder(binaryImage);
binaryImage = imfill(binaryImage, 'holes');
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Area');
largestRegionMask = labeledImage == index;
imshow(largestRegionMask)
Improved binary mask for the cell based on the above pointers.
Refer to the following links for more details on functions used in the code snippet:
Hope this helps in extracting the cell as a whole after “otsu thresholding”.
Regards,
Vinayak Luha