Multiple line fitting in binary image
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Harikrishnan Balachandran Nair
le 19 Oct 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 commentaires
Voir également
Catégories
En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!