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.

采纳的回答

Matt J
Matt J 2023-8-12
编辑:Matt J 2023-8-12
load('Edge_logical.mat')
imshow( edge(imfill(Edge_S1,'holes')) ,[])

更多回答(1 个)

Image Analyst
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');
If you want an image of the outer perimeter, you can use imfill and bwperim
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 个评论
Amjad Iqbal
Amjad Iqbal 2023-8-13
Thank you so much for providing the solution. The context of the query is to determine the actual size after applying compressive sensing to inverse SAR imaging (CS-ISAR). The objective is to quantitatively validate the sizes at different sparsity levels through overlapping. In this case, 50% of the data was used to reconstruct the image using our CS model.
I applied "thresholding" to the first image to isolate the target, resulting in the gray image in the middle. Then, I utilized the "edge" detection technique to identify the size from all sides.
The size of the outer edge was more relevant to the target. Once again, I truly appreciate the detailed guidelines you provided.
Image Analyst
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.

请先登录,再进行评论。

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by