Pixel Grouping in Image
显示 更早的评论
Hi everyone,
After thresholding, binarizing and removing small stray pixels, I have the following image:

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.

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);

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!
回答(1 个)
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.

类别
在 帮助中心 和 File Exchange 中查找有关 Image Segmentation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!