[Neuroimaging] Affine transformations

Matthew Brett matthew.brett at gmail.com
Thu Sep 6 05:32:44 EDT 2018


Oops,

On Fri, Aug 31, 2018 at 2:15 PM, Matthew Brett <matthew.brett at gmail.com> wrote:
[snip]
> I think you'll find that the center doesn't matter for the zooms
> because, if Z is a zooming affine, and hence of this form:
>
> Z = [[a, 0, 0, 0],
>        [0, b, 0, 0],
>        [0, 0, c, 0],
>        [0, 0, 0, 1]]
>
> then Tinv.dot(Z).dot(T) == Z for any translations in T.

How silly of me.  For some reason, as I woke up, I realized that's
obviously not true, and the zooms do change the translations, as would
have been obvious if I'd done the multiplication properly:

In [22]: import sympy as sy
In [23]: a, b, c, x, y, z = sy.symbols('a, b, c, x, y, z')
In [24]: T = Matrix([[1, 0, 0, x],
    ...:             [0, 1, 0, y],
    ...:             [0, 0, 1, z],
    ...:             [0, 0, 0, 1]])
    ...:
In [25]: Z = Matrix([[a, 0, 0, 0],
    ...:             [0, b, 0, 0],
    ...:             [0, 0, c, 0],
    ...:             [0, 0, 0, 1]])
    ...:
In [26]: T.inv() * Z * T
Out[26]:
Matrix([
[a, 0, 0, a*x - x],
[0, b, 0, b*y - y],
[0, 0, c, c*z - z],
[0, 0, 0,       1]])

So - yes - it does make a difference (to the origin) whether you zoom
after a translation, or not.

Sorry about that,

Cheers,

Matthew


More information about the Neuroimaging mailing list