Connect two objects to a single blob
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kamu
am 29 Mär. 2018
Kommentiert: Walter Roberson
am 29 Mär. 2018
Here is an example image of 2 objects. I want to fill the gap between those two to get a single blob. I tried with different morphological closing but could not get a smooth result as drawn in red.
Any help would be much appreciated.
Original Image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171677/image.png)
Desired mask:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171678/image.png)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 29 Mär. 2018
If you find() on the image to get the row and column coordinates, then you can use boundary() to get a list of indices into the row and columns that together, taken in order, give an outline that includes all of the points.
2 Kommentare
Walter Roberson
am 29 Mär. 2018
[y, x] = find(YourImage);
K = boundary(x, y);
boundary_x = x(K);
boundary_y = y(K);
mask = poly2mask( boundary_x, boundary_y, size(YourImage,1), size(YourImage,2) );
mask is now an ROI that is 1 for everywhere inside the combined object. Or you can
plot(boundary_x, boundary_y, 'r', 'linewidth', 4)
if what you care about is just drawing the outline rather than figuring out which points are inside of it.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!