Asked by bil bbil
on 17 Apr 2014

hello everyone

I really need help as soon as possible

I want a solution to calculate the diameter of each white line in the image(Vessel Diameter Measurement)

Answer by Sean de Wolski
on 17 Apr 2014

Accepted Answer

You might find the second part of this webinar helpful:

Sign in to comment.

Answer by Image Analyst
on 17 Apr 2014

Edited by Image Analyst
on 17 Apr 2014

It's pretty easy - maybe 3 lines of code. First call bwdist to get the distance from the white pixels to the nearest black pixel. Then call bwmorph to skeletonize that so you get the distances along the centerlines. That's the radius so multiply by two to get the diameter. It will be an image looking like a skeleton and to find the diameter you simply look at the value of the pixel at the location you want the diameter of. Basically it's this (untested):

edtImage = 2 * bwdist(~binaryImage);

skeletonImage = bwmorph(binaryImage, 'skel', inf);

diameterImage = edtImage * double(skeletonImage);

Can't get much simpler, though you may want to add a utility where you let the user call ginput() to report back the diameter at the closest pixel to where they clicked. It's pretty easy, though clever and not obvious (until you know about it), so most novices might embark on some complicated looping process to get cross sections (what a nightmare that would be).

Image Analyst
on 18 Apr 2014

bil - are you still around? Did it work?

bil bbil
on 20 Apr 2014

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## John D'Errico (view profile)

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/126064-how-to-calculate-the-diameter-of-a-vessel#comment_208529

Sign in to comment.