How can I calculate the thickness for the attached images?

How can I calculate the thickness for the attached image??
I did segmentation for all the nerves in the image and I labelled each object in the image. What I want is how can I calculate the thickness of each nerve? And how can I highlight a specific part of the nerve if there is an inflation in any nerve?
Your help in this regard is highly appreciated, thank you in advance

 Accepted Answer

Use regionprops to measure area and perimeter. Then assume blobs are long and thin. So area = length*width and perimeter = 2*w+2*l = 2*w+area/w. So
w*P = 2*w^2 + A
or
0 = 2*w^2-w*P + A
Use quadratic formula to solve
w = (P - sqrt(P^2-4*2*A))/(2*2)
w = (P-sqrt(P^2-8*A))/4

5 Comments

Dear Image Analyst
Thank you for your answer, Please, may you clarify your answer more. What do you mean by A and P? Please, see the second attached image. My goal is to make an image map in which the normal part of nerve will be, for example in green color, while the abnormal part of the nerve as determined in the red circle will be in red color. So, I thought I can use the thickness along the nerve and make checking if it exceeds the predefined limit, it will be abnormal, otherwise it is normal.
Oh that's easy, and you could do it in a few different ways. One is to just take the Euclidean distance transform with bwdist, and apply a colormap that has low values be green and higher values be red. A second way is to detach the thick part by using imerode, extract only that particular blob, then dilate it to enlarge it back to the original size, then add it back in so that it will have a value of 2 in the thick area instead of 1. Then apply a colormap where 0=black, 1-green, and 2=red.
Ok, I'll code it and see how is it going?
Dear Image analysis
I code your answer and it work perfectly, but I don't know how can set a specific color of each region. is there any idea??
In fact, I have the attached image, I completed the segmentation for all the nerves and I extract all the needed information from each nerve. My finall goal is if there is inflation in any nerve how can I detect it and make a final image map where the normal part of the nerve it should be green and the abnormal part let say red color, I used your method and it worked ok, but is there and suggestion how can I set different colors for the both parts either in the grayscale image or binary image?
T
hank you in advance
First you need to get a good binary image like you had before. Maybe you can just threshold it, or maybe use a Frangi filter or maybe use anisotropic diffusion (demo attached).
Then you need to use bwdist() to get the thickness of each place in the nerves. But the thickness will only be along the centerline of the distance transform and you want the entire thickness to be represented by some color, not just the centerline so you need to dilate out the centerline to that it takes up the whole binary image. To do this, use imdilate() which is a local max filter. Dilate it out a lot, like twice as big as the nerve. Then mask the dilated image by the original binary image to crop it to just the nerve boundaries. Now you have a solid color all the way out to the edge and you can simply apply a colormap. So the steps are
  1. process and get a binary image
  2. call bwdist
  3. call imdilate
  4. mask: out = dilatedImage .* binaryImage
  5. colorize: colormap().
If you have trouble, post your code.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!