MATLAB Answers

0

Diameter averaged mean intensity along the center-line of an image

Asked by Bernard Ikhimwin on 5 Nov 2018 at 11:35
Latest activity Commented on by Bernard Ikhimwin about 17 hours ago
My goal is to look for the diameter-averaged intensity of the attached image along the total center-line.
This is what I have in mind
  1. I intend to look for the centre-line of an image using bwmorph operation (this I can do).
  2. I intend to look for the branch points of the image, and subtract it from the center-line, to get discontinuous branches of the image (this I can do , using the morphological operations provided in Matlab).
  3. Finally I intend to look for the index of the pixels that are perpendicular to each pixel of the centre-line of every branch; after getting the indices of these pixels I can then use it to mask the original image, and find the mean intensity, which will be mapped to each center-line pixel of the image. I intend to plot the mean intensity as a function of the center-line.
My difficulty is in (3), I do not know how to get the index of pixels perpendicular to the center-line. I will be happy if any one can let me know how to implement this. Thank you very much as I anticipate your response.

  0 Comments

Sign in to comment.

1 Answer

Answer by Image Analyst
on 5 Nov 2018 at 11:44
 Accepted Answer

First get the skeleton with bwmorph(). Then get the distance transform with bwdist(). Then multiply those two images together. Then get the mean of all the non-zero elements. It should be like 3 or 4 lines of code.

  11 Comments

There Image Analyst, I'm not sure if I understand what image you are referring to, but the binary image I am referring to was attached in my response to you named ('shearstressformathwork.png'). It is true that the original image was a screen shot of the simulation I did on the network. Find below the code I used to make it binary.
if true
% code file= '\Users\matlabshearstress2';
F1 = imread(file,'png');
F2=im2bw(F1,0.0005);
F3=bwmorph(F2,'fill');
F3=bwmorph(F3,'fill');
%plot figure for binary image
figure(1)
image(255*F3);
colormap gray;
axis tight
axis equal
end
Bernard, that code doesn't do it. It leaves a white surround. I've cropped it properly and attached it.
But I'm not going to have time to write the program for you. It will take too much of my time and I can't afford to donate that to you. I've done it before so I know it's quite a lot of work. And sorry I can't give you the code because you'll have endless questions about it. All I can do is to tell you how I did it and you can do something similar. My user hand traced the curve, though for you, you'll get it from the skeleton. You'll have to use the 'branchpoints' option of bwmorph() to break apart your skeleton in to individual curve segments. Then, for each curve segment what you want to do is traverse it a pixel at a time. Then take a certain number of points before and after the current point and fit a quadratic to it. You can use the coefficients of the quadratic to get the slope of a line perpendicular to the curve at that point. Use the Euclidean distance transform (bwdist) to find the width of the binary branch (non-skeletonized) at that point. Then, with the slope and width, you can make endpoints of a line segment there and use improfile() to get the intensity on your gray scale image (not the binary image). After that it's a simple matter of using mean() to get the mean along the perpendicular profile.
Good luck.
Many thanks Image Analyst for your wonderful feedback. I really wanted to have an idea of how it is done. This makes sense. Thanks man.

Sign in to comment.