필터 지우기
필터 지우기

how to draw boundary of an image

조회 수: 2 (최근 30일)
rohith bharadwaj
rohith bharadwaj 2018년 4월 9일
답변: Arun Mathamkode 2018년 4월 20일
I want to draw a boundary for the image attached (input1). I've used the code written below. I'm getting the output as a file attached(output1). But I want to get only one boundary ( inside one). how can I get that? I just want inner boundary. don't want outer.
xt=imdilate(g2,s1); %%%dilating to get the edge region filled properly
binaryImage=xt;
boundaries = bwboundaries(binaryImage);
daries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
hold on;
fill(thisBoundary(:,2), thisBoundary(:,1),'w');
hold on;
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 1);
end
hold off
  댓글 수: 1
rohith bharadwaj
rohith bharadwaj 2018년 4월 10일
Help please. Input image is xt

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

답변 (1개)

Arun Mathamkode
Arun Mathamkode 2018년 4월 20일

The bwboundaries returns the possible boundaries in the input image as a cell array. Any specific boundary can be extracted by indexing the cell array. In your case boundaries{4} will return you the required inner boundary.

But if you want to perform the same task in different images, I think you can find boundaries with and without option 'noholes' and compare the extracted boundaries. The boundaries extracted with the default 'holes' option will contain all boundaries and the boundaries extracted with the default 'noholes' option will not contain the inner boundaries. You can refer doucumentation for bwboundaries for more details.

You can also try inverting the binary image and then find the boundaries with 'noholes' option.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by