pixel intensity gradient makes object detection by binary image segmentation fail

2 ビュー (過去 30 日間)
quinten Buvé
quinten Buvé 2022 年 1 月 19 日
回答済み: Ashish Uthama 2023 年 10 月 13 日
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