Skip to content

jitfields.resize

resize

resize(x, factor=None, shape=None, ndim=None, anchor='edge', order=2, bound='dct2', prefilter=True, out=None)

Resize a tensor using spline interpolation

Parameters:

Name Type Description Default
x `(..., *inshape) tensor`

Input tensor, with shape (..., *inshape).

required
factor `[sequence of] float`

Factor by which to resize the tensor (> 1 == bigger) One of factor or shape must be provided.

None
shape `[sequence of] float`

Shape of output tensor. One of factor or shape must be provided.

None
ndim `int`

Number if spatial dimensions. If not provided, try to guess from factor or shape. If guess fails, assume ndim = x.dim().

None
anchor `{'edge', 'center'} or None`

What feature should be aligned across the input and output tensors. If 'edge' or 'center', the effective scaling factor may slightly differ from the requested scaling factor. If None, the center of the (0, 0) voxel is aligned, and the requested factor is exactly applied.

'edge'
order `[sequence of] {0..7}`

Interpolation order.

2
bound `[sequence of] BoundType`

How to deal with out-of-bound values.

'dct2'
prefilter `bool`

Whether to first compute interpolating coefficients. Must be true for proper interpolation, otherwise this function merely performs a non-interpolating "prolongation".

True
out Optional[Tensor]

Output placeholder.

None

Returns:

Name Type Description
x `(..., *shape) tensor`

Resized tensor, with shape (..., *shape).

restrict

restrict(x, factor=None, shape=None, ndim=None, anchor='edge', order=1, bound='dct2', make_adjoint=False, out=None)

Restrict (adjoint of resize) a tensor using spline interpolation

Parameters:

Name Type Description Default
x `(..., *inshape) tensor`

Input tensor, with shape (..., *inshape).

required
factor `[sequence of] float`

Factor by which to resize the tensor (> 1 == smaller) One of factor or shape must be provided.

None
shape `[sequence of] float`

Shape of output tensor. One of factor or shape must be provided.

None
ndim `int`

Number if spatial dimensions. If not provided, try to guess from factor or shape. If guess fails, assume ndim = x.dim().

None
anchor `{'edge', 'center'} or None`

What feature should be aligned across the input and output tensors. If 'edge' or 'center', the effective scaling factor may slightly differ from the requested scaling factor. If None, the center of the (0, 0) voxel is aligned, and the requested factor is exactly applied.

'edge'
order `[sequence of] {0..7}`

Interpolation order.

2
bound `[sequence of] BoundType`

How to deal with out-of-bound values.

'dct2'
make_adjoint `bool`

Make restrict the numerical adjoint of resize by accumulating values into the output tensor. Otherwise, normalize by count to compute an average.

False
out Optional[Tensor]

Output placeholder.

None

Returns:

Name Type Description
x `(..., *shape) tensor`

Restricted tensor, with shape (..., *shape).