![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1450647/image.png)
Pixel Grouping in Image
22 views (last 30 days)
Show older comments
Hi everyone,
After thresholding, binarizing and removing small stray pixels, I have the following image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1450177/image.png)
and I essnetially aim to obtain ROI drawn around group of pixels.
However, I am having some trouble. I have tried with
activecontour(I_noholes,mask);
and
boundaries = bwboundaries(I_noholes);
with similar results, where the counturs were drawn around each individual detail within the desired ROIs, rather than around the group.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1450182/image.png)
I have also tried closing the image but I end up losing too much detail within the ROIs tehmselves, due to the pixels being too sparse and far from each other and ahving to use a base shape to close the image.
se = strel('disk',30);
I_closed = imclose(I_contour,se);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1450187/image.png)
Finally, I have a,lso tried convex hull but even using the "objects" parameter, it considers my entire circle as a giant hull, rather than going in an individually closing each sub group of pixels.
Any suggestions are welcome!
0 Comments
Answers (1)
Image Analyst
on 4 Aug 2023
As you found out, morphological things will change the shape of the binary blobs. This is a case for dbscan.
You can get all the (row, column) coordinates of the binary image from
[rows, columns] = find(binaryImage);
or if you prefer x,y
[y, x] = find(binaryImage);
help dbscan
See my attached dbscan demo, and adapt it. See in the picture below with randomly placed points, it found 7 clusters of points that were close to each other, and 10 isolated points that were not close enough to any other points to be considered as being part of a cluster.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1450647/image.png)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!