## Regionprops returning "wrong" axis lengths

on 12 Nov 2019

on 12 Nov 2019

### Guillaume (view profile)

I have a segmentation pipeline which produces a binary mask fitted to the outline of a cell. When I use regionprops to measure the mask, it gives the Major and Minor axis lengths to be ~25% larger than they appear. Below is a minimum working example, and attached is an example mask
theta = 0:0.01:2*pi;
figure(1)
hold on, axis image off
% Draw the ellipse on - for an ellipse with centre (x0, y0), semi-axis
% lengths (a,b), oriented at an angle phi above horizontal, the cartesian
% equations from the polar coordinates are as follows:
% x = a cos(theta) cos(phi) - b sin(theta) sin(phi) + x0
% y = a cos(theta) sin(phi) + b sin(theta) cos(phi) + y0
% Which is translated into indexed variables below
plot(0.5 * props.MajorAxisLength .* cos(theta) .* cos(props.Orientation) ...
- 0.5 * props.MinorAxisLength .* sin(theta) .* sin(props.Orientation)...
+ props.Centroid(1),... % x values end here
0.5 * props.MajorAxisLength .* cos(theta) .* sin(props.Orientation) ...
+ 0.5 * props.MinorAxisLength .* sin(theta) .* cos(props.Orientation)...
+ props.Centroid(2),'k--','LineWidth',2)
plot(props.Centroid(1),props.Centroid(2),'kx')
Here is the mask, with the measured ellipse drawn on.

R2019a

on 12 Nov 2019