pixel intensity gradient makes object detection by binary image segmentation fail

조회 수: 2 (최근 30일)
Hy, I'm using Otsu's segmentation for the transversion of a greyscale image to a binary image but In some images I encounter a problem. The oocyte that needs to be detected has a high intensity gradient and this is the reason why often only half of the oocyte is detected by means of Otsu's method.
Is there a way to preprocess your image in such a way that the oocyte is detected as 1 entity?
Thanks

답변 (2개)

VINAYAK LUHA
VINAYAK LUHA 2023년 10월 6일
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:
  1. Apply the dilation morphological transformations on the inverted binary mask obtained after “otsu thresholding”.
  2. Suppress the light structure connected to image border using the “imclearborder” function.
  3. Fill image region and holes using the “imfill” function.
  4. 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;
se = strel('disk', 2);
binaryImage = imdilate(binaryImage, se);
binaryImage = imclearborder(binaryImage);
binaryImage = imfill(binaryImage, 'holes');
imshow(binaryImage)
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Area');
areas = [props.Area];
[~, index] = max(areas);
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

Ashish Uthama
Ashish Uthama 2023년 10월 13일
You could consider using cellpose (available in 23b):
I see that you used a cropped image. If you have a larger image, you can directly use cellpose on it. If its 'very large', see this example which shows how to do this for 100kx100k or larger images.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by