File Exchange

image thumbnail


version by CY Y
Measure geometric properties (e.g. long axis, eccentricity, etc.) of image objects in 3D.


Updated 04 Oct 2016

GitHub view license on GitHub

regionprops3 measures the geometric properties of image objects in 3D space, including 'MajorAxis', 'MajorAxisLength', 'Centroid', 'AllAxes', and 'Eccentricity'.

Cite As

CY Y (2020). regionprops3 (, GitHub. Retrieved .

Comments and Ratings (12)

Matthew Pias

Came up with a simple fix for you problem @Ganesh, at least if you're trying to find the centroid as in my case. I inserted "if isempty(pixs) == 0" and put all of the code following that inside of this if statement

Faiza Bukenya

it doesnot compute area,diameter

Aya Eid


Nice work! Like it a lot. But still figuring evertything out.

Maybe a very basic question but: what happens here exactly? What formula is this based on?

distMat = sum(pixs.*repmat(eVectors(:,idx(1))',size(pixs,1),1),2);
output(ii).FirstAxisLength = range(distMat1);

Luke Xie

nice work



@Ganesh, have you checked if your image data contains any NaN or Inf ? Use this to check : any(isnan(img(:))|isinf(img(:))). If the result comes back as one, you'll have to fix that in the image.

Ganesh P G

Can someone help me with this error, please?

"Error using eig
Input to EIG must not contain NaN or Inf.

Error in regionprops3 (line 55)
[eVectors, eValues] = eig(covmat);"

My input for regionprops3 is a 3-D binary image. I removed objects with single pixel, because that was mentioned as a problem. It still gave me the error.



Serdar Yeralan, can you describe the difficulties in more details ? Did you get any error?

Serdar Yeralan

I am having difficulties with the function "struct2array" it calls. Any help would be greatly appreciated

Ilya Belevich

btw, could you please fix the function for the situations when the object consists of a single pixel.
For example,

L = zeros([5,5,5],'uint8');
L(3,3,3) = 1;
result = regionprops3(L, 'Eccentricity');
result = regionprops3(L, 'AllAxes');

thank you!

Ilya Belevich

Great function, thank you for sharing!


Updated description

linked to github

Correct minor mistake in the function

Correct a mistake in the previous version and add a few more outputs.

Summary edited

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux