EigenVectors and EigenValues from Regionprops3
1 view (last 30 days)
Show older comments
Hi
I am using regionprops3 to get eigenvectors and eigenvalues. Looks like the eigenvalues are sorted always. Am I right? The corresponding eigenvectors are in column or row?
Thanks.
3 Comments
Saurabh Patel
on 21 Sep 2018
Edited: Saurabh Patel
on 21 Sep 2018
Let us say, you want the orientation of some object in your image. You could essentially fit a line or plane to the set of points in that object and get the orientation of the line or plane. Matlab does better, RegionProps fits an ellipse or ellipsoid to the segmented object with conservation of second central moment. The major, intermediate, and minor axis radii of this ellipse are stored as eigenvalues. The orientation of these axes are stored in eigenvectors.
Answers (1)
Matt J
on 20 Sep 2018
Edited: Matt J
on 20 Sep 2018
We can investigate whether the eigenvectors are rows or columns using the single slice ellipse image below. Applying regionprops3 gives,
>> S=regionprops3(A,'Eigenvector','EigenValues'); S{1,1}{:}, S{1,2}{:}
ans =
0.1738 -0.9848 0
0.9848 0.1738 0
0 0 1.0000
ans =
897.8691
156.9113
0.0833
The largest eigenvalue 897.8961 corresponds to the long axis of the ellipse, which is therefore either the first column or row of the above 3x3 eigenvector matrix. However, as we can see from the image, the long axis of the ellipse points in a direction whose coordinates are the same sign (regardless of whether x,y or i,j coordinates are being used). Therefore, its corresponding eigenvector would be the first column, not the first row of the matrix.
Also, the size of the different components tells us that the first coordinate is the vertical axis and the second coordinate is the horizontal axis, indicating that the coordinate system used by regionprops3 is (i,j)-oriented in 2D, not (x,y)-oriented. This is oddly inconsistent with the conventions of all the 2D image processing toolbox functions. On the other hand, this inconsistency is consistent with the inconsistency between meshgrid and ndgrid :-)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196136/image.png)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!