Segment connected regions in binary image

6 vues (au cours des 30 derniers jours)
Adenine Koo
Adenine Koo le 5 Sep 2024
Commenté : Adenine Koo le 10 Sep 2024
Hi MATLAB community
I want to extract the area of these spherical structures from my binary image but there are circles which are too close to each other and hence became connected. I tried to use watershed to separate them but it does not work good enough. Also, I have half-opened circles (the crescent like structures) which bwareaopen is not helpful to close them too. Any suggestion is welcome!
  1 commentaire
Adenine Koo
Adenine Koo le 5 Sep 2024
This is the link to the raw tif image: 5KQ-005_RGB_488.tif

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 6 Sep 2024
  10 commentaires
Image Analyst
Image Analyst le 10 Sep 2024
Is there a minimum size? So is there a size for which you only want blobs larger than that size? Like, can we ignore small blobs? Or blobs with no holes?
Adenine Koo
Adenine Koo le 10 Sep 2024
Probably no, they can be of a variety of sizes, but you are right, I guess I will have to sacrifice the very small one just to eliminate the background glitches too. I do want to include bigger blobs without holes.

Connectez-vous pour commenter.

Plus de réponses (1)

Shivansh
Shivansh le 6 Sep 2024
Modifié(e) : Shivansh le 6 Sep 2024
Hi Adenine!
It seems like you are having issues in identifying the circles present in your image.
You can start by applying a Gaussian blur to reduce noise, followed by adaptive thresholding for more effective segmentation.
You can then use "imclose" to fill gaps in half-opened circles. You can also try to compute the distance transform with "bwdist" and apply a marker-controlled watershed technique. If the spherical structures are circular, the Hough Transform via "imfindcircles" can be quite useful for detecting and distinguishing these shapes.
You can refer to the below script for reference:
I = imread('5KQ-005_RGB_488.tif');
if size(I, 3) == 3
I = rgb2gray(I);
end
% Apply Gaussian blur
I_blur = imgaussfilt(I, 2);
% Convert to binary image
bw = imbinarize(I_blur, 'adaptive', 'Sensitivity', 0.5);
% Apply morphological closing to fill gaps
se = strel('disk', 5);
bw_closed = imclose(bw, se);
% Compute the distance transform
D = -bwdist(~bw_closed);
% Set background pixels to -Inf
D(~bw_closed) = -Inf;
% Apply watershed transform
L = watershed(D);
% Display the labeled image
imshow(label2rgb(L, 'jet', 'w', 'shuffle'));
You can experiment with different combinations of techniques and parameters to analyze the results for your case.
If you don't get the desired results, you can also look towards deep learning related approaches.
You can refer to the following documentation link for DL related approaches: https://www.mathworks.com/help/images/deep-learning.html.
I hope this helps in resolving your issue.
  1 commentaire
Adenine Koo
Adenine Koo le 6 Sep 2024
This is roughly how I do it in the beginning which does not work well, but the DL based approach is something worth looking at! Thanks!

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by