How to change boundary width in Active Contour Method?

3 ビュー (過去 30 日間)
Tawsif Mostafiz
Tawsif Mostafiz 2021 年 6 月 28 日
回答済み: Tawsif Mostafiz 2021 年 6 月 28 日
Hi, I am writing a code, where I am using active contour method for segmentation. The relevent part looks like this:
bw1=activecontour(image,B0,iteration,'Chan-Vese');
Where B0 is the area on which the segmentation is to be performed, ieration is number of iterations.
the output is shown by the lines,
imshow(image)
hold on
visboundaries(bw1);
hold off
When I run the code for this image,
The output is like this:
But as you can see, the red boundary line is too thick and has white around it. I want to make the line thinner with no white around. How do I do it?

採用された回答

Steve Eddins
Steve Eddins 2021 年 6 月 28 日
Call visboundaries with an output argument. That output argument will be an hggroup object containing two lines. You can then manipulate properties of the two lines directly. Here is an example:
I = imread('toyobjects.png');
mask = false(size(I));
mask(50:150,40:170) = true;
bw = activecontour(I,mask,200,'edge');
imshow(I)
hold on
h = visboundaries(bw,'Color','r')
h =
Group with properties: Children: [2×1 Line] Visible: on HitTest: on Show all properties
hold off
h.Children(1)
ans =
Line with properties: Color: [1 0 0] LineStyle: '-' LineWidth: 2 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1×351 double] YData: [1×351 double] ZData: [1×0 double] Show all properties
h.Children(2)
ans =
Line with properties: Color: [1 1 1] LineStyle: '-' LineWidth: 3 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1×351 double] YData: [1×351 double] ZData: [1×0 double] Show all properties
h.Children(2).Visible = 'off';
h.Children(1).LineWidth = 1;

その他の回答 (1 件)

Tawsif Mostafiz
Tawsif Mostafiz 2021 年 6 月 28 日
Thanks @Steve Eddins! It works beautifully!

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by