-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IntertiaEllipsoid #27
Comments
Hi, In short:
Does it helps? |
"Euler angles are a nightmare..." I could not agree more! Incredible how much time I spend lately understanding all the different ways of rotating objects in 3D. My issue is that I am using basically using your code for "Ellipsoid fitting": Related to this: how do I properly cite MorphoLibJ in my code? And then I use this function to convert it to a AffineTransform: This works almost always nice, but in some cases the transformation looks like as if the axes were not found properly. The longest axis is aligned but the shortest not. Now I do not know whether something goes wrong during the moments computation or whether there is a problem with the way that I compute the transformation.... |
I added a test: https://github.com/tischi/fiji-plugin-morphometry/blob/master/src/test/java/TestEllipsoidFitting.java#L23 If you wish you could just clone my repo and try yourself. Running the MLJ code I just get different rotations of 180 degrees, which should do nothing in terms of aligning those axes, should it? I guess I am doing something wrong? For the 3D ImageSuite, the last vector appears to point into the direction of the long axis.
|
Hi, well, ellipsoids are symmetric, so having a rotation by 180 around one of the principal axes of the ellipsoid does not fundamentally changes the result! Anyway, I think the differences come from the way the inertia matrix is converted into a triplet of angles. I will check more carefully, but this should be rather similar. I have committed a small update, that isolates the computation of the inertia coefficients -> this should make it easier to test/check and/or adapt. Also, to cite MorphoLibJ, the best is to use the paper published in BioInformatics in 2016: https://academic.oup.com/bioinformatics/article/32/22/3532/2525592 |
...that was my point: The angles that MLJ currently gives do not contain the information that the longest ellipsoid axis is relatively rotated by 90 degrees in the two examples that I tested (for both cases one just gets rotations around 180 degrees instead of one of them yielding a 90 degrees rotation). First ellipsoid:MLJ angles (Phi, Theta, Psi): Second ellipsoid:MLJ angles (Phi, Theta, Psi): |
Hi, I has a better look at the code, and found the problem. In fact it arise only when object is very well aligned with y axis... |
Thanks a lot! |
I tried it and it now handles the cases above properly! However I am still struggling with one data set. I only manage to get it aligned along the axes of the coordinate system the second time I run it through the alignment procedure, which is weird:
Only at "round 3" the axes are along the coordinate system => the first rotation does not suffice. The data set is here: https://github.com/tischi/fiji-plugin-morphometry/blob/master/src/test/resources/dapi_mask_2.zip On another note: what about also outputting the the 3 major axes as vectors that way that the 3d-ImageSuite is doing it? I think this would be great, because:
|
Hi, So, I agree with you, returning the major axes as vectors is a good idea! I try to include it soon. |
Hi! I have also started an implementation of an utility "EulerAnglesXYZ" class, to isolate parts of the computation. It can be found in the "geometry" branch. By the way, what is the goal of your script? Do you want to perform principal axis transform? in that case, I agree: the best isto keep the vectors, build the transform matrix, and apply the transform (or its inverse) to the image. |
Here is a link on a pdf I used for writing the conversion code from rotation matrix to Euler angles: |
Just to finalize the thread, I have included modification on computation of equivalent ellipsoid into latest version of MorphoLibJ (1.4.1). The user manual was also updated to include all the necessary explanations. Best, |
Excellent! Thank you! |
Hi, For the "inertia ellipsoid", it seems definitions are more related to mechanics. Main source is Wikipedia. You can also see https://uk.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/48913/versions/4/screenshot.jpg , or issue #30 |
@dlegland
hi David, I have a question related to this:
https://github.com/ijpb/MorphoLibJ/blob/master/src/main/java/inra/ijpb/measure/region3d/InertiaEllipsoid.java#L302
Which convention do you follow for those angles? In other words, how would I have to rotate an object to align it with respect to those angles. There seem to be different versions as to which angle you rotate around which axis in which order. Thank you very much for your help!
The text was updated successfully, but these errors were encountered: