Multiple line fitting in binary image
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jan Kubicek
el 23 de Sept. de 2021
Respondida: Harikrishnan Balachandran Nair
el 19 de Oct. de 2021
Dear colleagues,
I would like to kindly ask you on the issue with multiple line fitting in MATLAB. I have a binary image with multiple skeletons, and I need to perform fitting of each line in this image by continous curve. I am able to do that for one line, see the code. Nevertheless, I am unable to do that for the all the lines at once automaticaly and plot the fitting results.
I use the image labeling: bwlabel() to recognize individual lines and for the fitting, I use the function smooth().
I would like to kindly ask you for the help with this task.
Thank you very much in advance.
I use the following code:
i=imread('test.png');
image=i(:,:,2);
BW = logical(image);
BW1=bwskel(BW);
[skel_label N]=bwlabel(BW1);
figure()
imshow(BW1)
[r s]=size(skel_label);
for ii=1:r
for jj=1:s
if skel_label(ii,jj)==2
skel_label_mod(ii,jj)=1;
else
skel_label_mod(ii,jj)=0;
end
end
end
[coor1 coor2]=find(skel_label_mod);
yy1 = smooth(coor2,coor1,0.5,'loess');
figure()
imshow(i)
hold on
plot(coor2,yy1,'x')
0 comentarios
Respuestas (1)
Harikrishnan Balachandran Nair
el 19 de Oct. de 2021
Hi,
I understand that you are trying to use the 'smooth' function on each of the connected components/curved lines that you got using the 'bwskel' function.
Using the 'bwlabel' fuction, each of the connected component in the corresponding image can be given a label number. This label can be used with the 'find' function to smooth the line with the corresponding label number. You can refer to the following code.
[skel_label N]=bwlabel(BW1);
figure()
imshow(i)
hold on;
for i=1:N
[coor1 coor2]=find(skel_label==i); % Finding all the co-ordinates for the corresponding component
yy1 = smooth(coor2,coor1,0.5,'loess');
plot(coor2,yy1,'x');
end
hold off;
0 comentarios
Ver también
Categorías
Más información sobre 3-D Volumetric Image Processing 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!