5 views (last 30 days)

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.

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);

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.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.