How to remove inner edge of the target?

조회 수: 1 (최근 30일)
Amjad Iqbal
Amjad Iqbal 2023년 8월 12일
댓글: Image Analyst 2023년 8월 13일
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
Amjad Iqbal
Amjad Iqbal 2023년 8월 12일
Thank you so much for your prompt response and its helpful for me.

댓글을 달려면 로그인하십시오.

추가 답변 (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