How to get the centerline of a binary region

23 visualizaciones (últimos 30 días)
Sam Ade
Sam Ade el 17 de Oct. de 2021
Comentada: Woj el 11 de En. de 2023
I have a binarize image below, I am trying to find the centerline of the image such as that in red on the binarize image. I did use the bskel function but get branches. I am hoping to elimated (prone or remove) all branches.
Any suggestions will be most appreciated. Any other way to do this another than using bskel will be great too.

Respuesta aceptada

DGM
DGM el 17 de Oct. de 2021
There's this.
A = imread('arc.png')>128;
B = bwmorph(A,'skel',inf); % skeletonize
B = imfill(B,'holes'); % get rid of any tiny closed paths
B = bwmorph(B,'skel',inf); % finish skeletonizing
% remove endpoints until only two are left
while true
e = bwmorph(B,'endpoints');
if nnz(e)>2
B = B & ~e;
else
break;
end
end
imshow(B)

Más respuestas (1)

KSSV
KSSV el 17 de Oct. de 2021
You can get the indices of white pixels using find and to the data you can try fitting a line or quadratic equation using polyfit.
[y,x] = find(I) ;
p = polyfit(x,y,2) ;
xi = linspace(min(x),max(x)) ;
yi = polyval(p,xi) ;
plot(X,y,'.k')
hold on
plot(xi,yi,'r')
  5 comentarios
Matheus Ferreira
Matheus Ferreira el 8 de Jun. de 2022
Great, thank you! Worked perfect!
Woj
Woj el 11 de En. de 2023
Hi. Sry for the stupid question, but im very very new to matlab. I have exactly the same problem, but i dont understand how do i find the white pixels?
thank you

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by