Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
a5073f9d
Commit
a5073f9d
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: transform.decompose accepts 3x3 matrix
parent
077fd7eb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/transform.py
+11
-6
11 additions, 6 deletions
fsl/utils/transform.py
with
11 additions
and
6 deletions
fsl/utils/transform.py
+
11
−
6
View file @
a5073f9d
...
...
@@ -178,7 +178,7 @@ def decompose(xform, angles=True):
It is assumed that the given transform has no perspective components. Any
shears in the affine are discarded.
:arg xform: A ``(4, 4)`` affine transformation matrix.
:arg xform: A
``(3, 3)`` or
``(4, 4)`` affine transformation matrix.
:arg angles: If ``True`` (the default), the rotations are returned
as axis-angles, in radians. Otherwise, the rotation matrix
...
...
@@ -187,7 +187,8 @@ def decompose(xform, angles=True):
:returns: The following:
- A sequence of three scales
- A sequence of three translations
- A sequence of three translations (all ``0`` if ``xform``
was a ``(3, 3)`` matrix)
- A sequence of three rotations, in radians. Or, if
``angles is False``, a rotation matrix.
"""
...
...
@@ -198,9 +199,13 @@ def decompose(xform, angles=True):
# The next step is to extract the translations. This is trivial;
# we find t_x = M_{4,1}, t_y = M_{4,2}, and t_z = M_{4,3}. At this
# point we are left with a 3*3 matrix M' = M_{1..3,1..3}.
xform
=
xform
.
T
translations
=
xform
[
3
,
:
3
]
xform
=
xform
[:
3
,
:
3
]
xform
=
xform
.
T
if
xform
.
shape
==
(
4
,
4
):
translations
=
xform
[
3
,
:
3
]
xform
=
xform
[:
3
,
:
3
]
else
:
translations
=
np
.
array
([
0
,
0
,
0
])
M1
=
xform
[
0
]
M2
=
xform
[
1
]
...
...
@@ -261,7 +266,7 @@ def decompose(xform, angles=True):
if
angles
:
rotations
=
rotMatToAxisAngles
(
R
.
T
)
else
:
rotations
=
R
.
T
return
[
sx
,
sy
,
sz
],
translations
,
rotations
return
np
.
array
(
[
sx
,
sy
,
sz
]
)
,
translations
,
rotations
def
rotMatToAffine
(
rotmat
,
origin
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment