tomopy.misc.morph

Module for data size morphing functions.

Functions:

downsample(arr[, level, axis])

Downsample along specified axis of a 3D array.

upsample(arr[, level, axis])

Upsample along specified axis of a 3D array.

pad(arr, axis[, npad, mode, ncore])

Pad an array along specified axis.

sino_360_t0_180(data[, overlap, rotation])

Converts 0-360 degrees sinogram to a 0-180 sinogram.

trim_sinogram(data, center, x, y, diameter)

Provide sinogram corresponding to a circular region of interest by trimming the complete sinogram of a compact object.

tomopy.misc.morph.downsample(arr, level=1, axis=2)[source]

Downsample along specified axis of a 3D array.

Parameters
  • arr (ndarray) – 3D input array.

  • level (int, optional) – Downsampling level in powers of two.

  • axis (int, optional) – Axis along which downsampling will be performed.

Returns

ndarray – Downsampled 3D array in float32.

tomopy.misc.morph.pad(arr, axis, npad=None, mode='constant', ncore=None, **kwargs)[source]

Pad an array along specified axis.

Parameters
  • arr (ndarray) – Input array.

  • axis (int) – Axis along which padding will be performed.

  • npad (int, optional) – New dimension after padding.

  • mode (str or function) – One of the following string values or a user supplied function.

    ‘constant’

    Pads with a constant value.

    ‘edge’

    Pads with the edge values of array.

  • constant_values (float, optional) – Used in ‘constant’. Pad value

  • ncore (int, optional) – Number of cores that will be assigned to jobs.

Returns

ndarray – Padded 3D array.

tomopy.misc.morph.sino_360_t0_180(data, overlap=0, rotation='left')

Converts 0-360 degrees sinogram to a 0-180 sinogram.

If the number of projections in the input data is odd, the last projection will be discarded.

Parameters
  • data (ndarray) – Input 3D data.

  • overlap (scalar, optional) – Overlapping number of pixels.

  • rotation (string, optional) – Left if rotation center is close to the left of the field-of-view, right otherwise.

Returns

ndarray – Output 3D data.

tomopy.misc.morph.sino_360_to_180(data, overlap=0, rotation='left')[source]

Converts 0-360 degrees sinogram to a 0-180 sinogram.

If the number of projections in the input data is odd, the last projection will be discarded.

Parameters
  • data (ndarray) – Input 3D data.

  • overlap (scalar, optional) – Overlapping number of pixels.

  • rotation (string, optional) – Left if rotation center is close to the left of the field-of-view, right otherwise.

Returns

ndarray – Output 3D data.

tomopy.misc.morph.trim_sinogram(data, center, x, y, diameter)[source]

Provide sinogram corresponding to a circular region of interest by trimming the complete sinogram of a compact object.

Parameters
  • data (ndarray) – Input 3D data.

  • center (float) – Rotation center location.

  • x, y (int, int) – x and y coordinates in pixels (image center is (0, 0))

  • diameter (float) – Diameter of the circle of the region of interest.

Returns

ndarray – Output 3D data.

tomopy.misc.morph.upsample(arr, level=1, axis=2)[source]

Upsample along specified axis of a 3D array.

Parameters
  • arr (ndarray) – 3D input array.

  • level (int, optional) – Downsampling level in powers of two.

  • axis (int, optional) – Axis along which upsampling will be performed.

Returns

ndarray – Upsampled 3D array in float32.