-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
This sentence is confusing: "The first (last) axis in a coordinate system is the top (bottom) entry in the column vector".
It reads like "first" really means "last" and "top" really means "bottom"!
I'm kinda confused by the ways that the spec represents matrices.
The example at https://ngff-spec.readthedocs.io/en/latest/specification.html#matrix-transformations could be more realistic to help illustrate the concepts.
It looks like a matrix for a 3D image (x, y, z), but a matrix for a 3D image is a 4 x 4 matrix?
E.g. what does a matrix look like for a 3D image that is rotated 30 degrees in the Z axis?
Playing around with napari's helpers...
from napari.utils.transforms import Affine
# This looks clear - if I want to scale a 4D image by 2 in x and y. The affine matrix is a 5 x 5 with the first 4 columns being `C, Z, Y, X`.
Affine(scale=[1,1,2,2]).affine_matrix
array([[1., 0., 0., 0., 0.],
[0., 1., 0., 0., 0.],
[0., 0., 2., 0., 0.],
[0., 0., 0., 2., 0.],
[0., 0., 0., 0., 1.]])
# This looks like a rotation matrix for a 2D image, with a 3 x 3 matrix and the first columns being `Y, X`.
>>> Affine(rotate=30).affine_matrix
array([[ 0.8660254, -0.5 , 0. ],
[ 0.5 , 0.8660254, 0. ],
[ 0. , 0. , 1. ]])
# If I have an image that is `C, Y, X`, and I want to rotate it in the Z axis (X and Y coordinates change) this looks like the correct matrix - 4 x 4 matrix with the first 3 columns being `C, Y, X`.
Affine(rotate=[0, 0, 30]).affine_matrix
array([[ 1. , 0. , 0. , 0. ],
[ 0. , 0.8660254, -0.5 , 0. ],
[ 0. , 0.5 , 0.8660254, 0. ],
[ 0. , 0. , 0. , 1. ]])
# The `rotate=[0, 0, 30]` represents [yaw, pitch, roll]`.
# Same result with:
Affine(rotate=30).expand_dims([0]).affine_matrix
array([[ 1. , 0. , 0. , 0. ],
[ 0. , 0.8660254, -0.5 , 0. ],
[ 0. , 0.5 , 0.8660254, 0. ],
[ 0. , 0. , 0. , 1. ]])
Some examples like this would help to clarify.
Metadata
Metadata
Assignees
Labels
No labels