How to remove inner edge of the target?
1 次查看(过去 30 天)
显示 更早的评论
Hello dear MATLAB Experts,
I have attached an image of a target. When I apply the "edge" function to this target, I obtain both inner and outer edges. However, the actual edges of my target, in terms of size, correspond to the outer ones. How can I remove the inner edges?
".mat" file is attached data for binary image and edge image.
I am grateful for your kind guidance.
0 个评论
采纳的回答
更多回答(1 个)
Image Analyst
2023-8-12
What do you want to do? Why did you use edge() instead of simply thresholding?
Anyway, if you want a list of outer boundary coordinates, you can use bwboundaries
boundaries = bwboundaries(binaryImage, 'noholes');
filledMask = imfill(binaryImage, 'holes');
perimeterImage = bwperim(filledMask);
This looks like an XY problem https://en.wikipedia.org/wiki/XY_problem so your suggested approach might not be the optimal one, but we don't know because you didn't share the use case or context. Happy to hear more if you want better advice.
2 个评论
Image Analyst
2023-8-13
Yeah, like I thought. You really didn't need to do an edge detection like you thought. If you want the area of the non-filled blob, you can do
props = regionprops(mask, 'Area');
donutArea = [props.Area]; % Area(s) of each blob in the image.
or you can do
donutArea = bwarea(mask); % Area of all blobs in image.
If you want the outer perimeter length you can get it from using regionprops on the filled mask:
props = regionprops(filledMask, 'Area', 'Perimeter');
perimeters = [props.Perimeter]; % Perimeter(s) of each blob in the image.
The problem with doing edge detection is that sometimes you get two edges (an inner one and an outer one) and sometimes they may not overlap the actual perimeter.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!