Search code examples
imagematlabimage-processing3d

Estimate branch length for a skeleton image in 3D


What is the correct way to estimate the branch length from a skeletonized 3d volume? I have tried the following code but I got Nans and Inf. Is my method correct?

skeleton = bwskel(logical(V));
branch_points = bwmorph3(skeleton, 'branchpoints');
end_points = bwmorph3(skeleton, 'endpoints');
branch_length = bwdistgeodesic(branch_points, end_points);

Solution

  • If you read the documentation to bwdistgeodesic, you’ll see it doesn’t compute the distance from points in one image to points in the other. Rather, it computes the geodesic distance transform of one image w.r.t. points in the other. That is, instead of passing in start points and end points, pass in the skeleton and the start points, then read the distances at the end points in the resulting image (code not tested):

    gdt = bwdistgeodesic(skeleton,branch_points);
    branch_lengths = gdt(end_points);