Detect and Fill Edges of a Binary Image

6 Ansichten (letzte 30 Tage)
Carolyn
Carolyn am 16 Mai 2018
Beantwortet: Akira Agata am 24 Mai 2018
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.

Akzeptierte Antwort

Akira Agata
Akira Agata am 24 Mai 2018
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)

Weitere Antworten (0)

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by