MATLAB Answers

How can I find the coordinates of the top and bottom end plate and calculate the height?

4 views (last 30 days)
Chloe Tan
Chloe Tan on 5 Feb 2020
Edited: Matt J on 6 Feb 2020
Hi all,
I am trying to automate the calculation of each height of the vertebra.
I have bwlabel my binary image so that it labels 1 to 24 from top to bottom.
I have used regionprops the get the centroid and bounding box. I understand that the boundingbox does give the height and width however it does not trully reflect the height of each vertebra as some of them are at an angle. (1st picture)
bwboundaries does give me all the coordinates of the boundaries but how do I use that to find an average of height of each of the vertebra? (2nd picture)
Or is there a way to run through the image in a way that I can get 3 coordinates from the top and the bottom end plate of the vertebrae respectively, find the average height and perhaps draw a line through the 3 coordinates?
My end goal is to be able to find the height and draw a line through the top and bottom end plate of each vertebrae if possible like the image below.

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 5 Feb 2020
Edited: Matt J on 6 Feb 2020
The FEX submission pgonCorners (Download) can be used to find approximate corners for each of the vertebrae. Once you have the corner points, you can draw lines through the ones with similar vertical coordinates to demarcate the end plates. You can also average the vertical coordinates of the 4 vertices to define an overall height for each vertebra.
load spine
[m,n]=size(BW);
A=false(m,n);
R=regionprops(BW,'PixelIdxList');
Nv=numel(R); %number of vertebrae
corners=cell(1,Nv);
imshow(BW)
for i=1:Nv
B=A;
B(R(i).PixelIdxList)=1;
corners{i} = pgonCorners(B,4,40);
hold on
plot( corners{i}(:,2),corners{i}(:,1),'ro','MarkerFaceColor','m');
hold off
end
heights=cellfun(@(c) mean(c(:,1)),corners);
[heights,idx]=sort(heights);
corners=corners(idx);

  3 Comments

Chloe Tan
Chloe Tan on 5 Feb 2020
Thank you very much for your reply Matt, really appreciate it.
Can you explain this line of code why 40 is used in the pgonCorners for N
corners{i} = pgonCorners(B,4,40);
I dont quite get the meaning of N-Number of samples partitioning the unit circle (default=360).
Matt J
Matt J on 5 Feb 2020
Roughly speaking, the algorithm used by pgonCorners.m works by looking at lines of various incline angles/slopes and checking where they intersect the vertebra boundary tangentially (see also here). N is the number of incline angles between 0 and 360 degrees used in the search.
The algorithm was intended for convex polygons, which are usually not so sensitive to the choice of N. Unfortunately, for your image, some of the vertebrae (like the one below) are not well-modeled as convex quadrilaterals, so finding the optimal N is something of a trial-and-error business.
One thing you can do to reduce the sensitivity to N is to seach for more than 4 vertices, like below. However, you might then need more complicated analysis to decide which pairs of vertices correspond to the end plates.

Sign in to comment.

More Answers (0)