Detect and Fill Edges of a Binary Image

3 ビュー (過去 30 日間)
Carolyn
Carolyn 2018 年 5 月 16 日
回答済み: Akira Agata 2018 年 5 月 24 日
I have this image that I have created from a point cloud. I want to connect the inner and outer rings and fill the region between them with 1s. Any suggestions? I tried creating a boundary of the scatter data, but I couldn't enclose the region with that. I can't use bwboundary because the points aren't currently connected. I would love to connect them then use that function if possible.

採用された回答

Akira Agata
Akira Agata 2018 年 5 月 24 日
Assuming that the inner/outer ring can be approximated by the edge of convex hull of inner/outer ring points, the area between inner and outer ring can be extracted by the following:
% Read and prepare the binary image
I = imread('Slice.jpg');
Igray = rgb2gray(I);
BWin = imbinarize(Igray);
BWin = imclearborder(BWin);
% Convex hull of outer ring points
CH1 = bwconvhull(BWin);
% Remove outer ring points
se = strel('disk',10);
CH1b = imerode(CH1,se);
BW1 = BWin & CH1b;
% Convex hull of inner ring points
CH2 = bwconvhull(BW1);
% Extract the area between inner and outer convex hull
BWout = CH1 - CH2;
% Show the result
figure
imshowpair(BWin,BWout)

その他の回答 (0 件)

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by