tomosipo.scale

tomosipo.scale(scale, *, pos=0, alpha=1.0)[source]

Create a scaling transform

The scaling transform scales the coordinate frame of the object by alpha * scale around position pos.

Parameters:
  • scale

    By how much to scale in each direction. The parameter scale is interpreted as a series of homogeneous coordinates. You may pass in both homogeneous or non-homogeneous coordinates. Also, you may pass in multiple rows for multiple timesteps. The following shapes are allowed:

    • scalar

    • (n_rows, 3) [non-homogeneous] or (n_rows, 4) [homogeneous]

    • (3,) [non-homogeneous] or (4,) [homogeneous]

  • pos – Scale around a custom position. The default is to scale around the origin.

  • alpha – Multiply the scaling by alpha. This is useful if you want the scaling to be time-dependent.

Returns:

A transform describing the scaling

Return type:

Transform

Examples

>>> ts.scale(2)
Transform(
    [[[2. 0. 0. 0.]
  [0. 2. 0. 0.]
  [0. 0. 2. 0.]
  [0. 0. 0. 1.]]]
)
>>> ts.scale((2, 2, 2), pos=(3, 4, 5))
Transform(
    [[[ 2.  0.  0. -3.]
  [ 0.  2.  0. -4.]
  [ 0.  0.  2. -5.]
  [ 0.  0.  0.  1.]]]
)
>>> ts.scale(1, alpha=[2, 3])
Transform(
    [[[2. 0. 0. 0.]
  [0. 2. 0. 0.]
  [0. 0. 2. 0.]
  [0. 0. 0. 1.]]

 [[3. 0. 0. 0.]
  [0. 3. 0. 0.]
  [0. 0. 3. 0.]
  [0. 0. 0. 1.]]]
)

Note that all parameters must have broadcastable length. Otherwise an error is raised.

>>> ts.scale(np.ones((2,3)), pos=np.ones((4, 3)), alpha=np.ones(5))
Traceback (most recent call last):
...
ValueError: Expected `scale`, `pos`, and `alpha` to be broadcastable. Got lengths: 2, 4, and 5.