tree - How do I connect two broken lines along the same direction in matlab -
i'm trying select vessel branch based on user selection.
i've got center lines extracted , removed branch points big gap. i'm thinking if user click on vessel starting point, trace way until meeting branch: if it's 3-line crossing both lines belonging branch. if it's 4-lines crossing, vertical-ish line belongs same branch , other horizontal-ish lines belongs branch, not selected.
how can done? result imagined..
i think got decent results using imerode , thinning values obtained trail , error, may not generic solution. notice top of "tree" disappears. i've included last image.
%if image isn't binary turn logical array bwim = im2bw(im); %13 came trial , error, can play shape , use %besides disk thick = imerode(bwim,strel('disk',13)); %the infinite means untill no changes occur. use ~thick becasue thin %works on 1 pixels, not 0's. invert output of bwmorph our %image 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');
this looks pretty good, better start high quality image rather start bad 1 , lots of post processing. suggest applying contrast enhancement (like histogram equalization easy choice) region of interest. might have crop out black background (or if cant maybe replace average gray value of image) before performing contrast enhancement. after extract veins, maybe won't need connect broken pieces @ point.
good luck
Comments
Post a Comment