How to connect two dashed lines in one direction in Matlab

I am trying to select a ship branch based on user selection.
I have already extracted the center lines and removed the branch points with a large gap. What I'm going to do is if the user clicks on the ship as a starting point, then he will be traced to the meeting with the branch: if this is a three-line intersection, then both lines belong to this branch. if it crosses 4 lines, the vertical-ish line belongs to one branch, and the other horizontal-force lines belong to another branch, therefore they are not selected. enter image description here

How can I do that? this is what i imagined.

enter image description here

+4
source share
1

, , imerode . , . , "" . .

%if your image isn't already binary turn it into a logical array
bwim = im2bw(im);

%13 came by trial and error, you can also play with the shape and use something
%besides a disk
thick = imerode(bwim,strel('disk',13));

%the infinite means do untill no changes occur. we use ~thick becasue thin
%works on 1 pixels, not 0's. we then invert the output of bwmorph to get our
%image back to normal (0 foregroun 1 background)
thinned = ~bwmorph(~thick,'thin',inf);

figure(1);imshow(bwim);title('original');
figure(2);imshow(thick);title('after erosion');
figure(3);imshow(thinned);title('after thining');

enter image description here

, , . (, - ) . , ( ), . , , .

0

All Articles