Multiple line fitting in binary image

2 ビュー (過去 30 日間)
Jan Kubicek
Jan Kubicek 2021 年 9 月 23 日
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')

回答 (1 件)

Harikrishnan Balachandran Nair
Harikrishnan Balachandran Nair 2021 年 10 月 19 日
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;

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by