Skip to content

ImageReslice

Introduction

vtkImageReslice - Reslices a volume along a new set of axes

vtkImageReslice is the swiss-army-knife of image geometry filters: It can permute, rotate, flip, scale, resample, deform, and pad image data in any combination with reasonably high efficiency. Simple operations such as permutation, resampling and padding are done with similar efficiently to the specialized vtkImagePermute, vtkImageResample, and vtkImagePad filters. There are a number of tasks that vtkImageReslice is well suited for:

  1. Application of simple rotations, scales, and translations to an image. It is often a good idea to use vtkImageChangeInformation to center the image first, so that scales and rotations occur around the center rather than around the lower-left corner of the image.
  2. Extraction of slices from an image volume. The method SetOutputDimensionality(2) is used to specify that want to output a slice rather than a volume. You can use both the resliceAxes and the resliceTransform at the same time, in order to extract slices from a volume that you have applied a transformation to. Note: vtkImageReslice uses column-major format.

Methods

applyTransform

Apply newTrans, then translate by -origin, then scale by inInvSpacing

ArgumentTypeRequiredDescription
newTransYes
inPointYes
inOriginYes
inInvSpacingYes

Returns

TypeDescription

canUseNearestNeighbor

ArgumentTypeRequiredDescription
matrixYes
outExtYes

Returns

TypeDescription

clamp

Internal function uses vtkInterpolationMathClamp on numscalars * n elements

ArgumentTypeRequiredDescription
outPtrYes
inPtrYes
numscalarsYes
nYes
minYes
maxYes

Returns

TypeDescription
The number of elements processed

convert

Internal function uses Math.round on numscalars * n elements

ArgumentTypeRequiredDescription
outPtrYes
inPtrYes
numscalarsYes
nYes

Returns

TypeDescription
The number of elements processed

extend

Method used to decorate a given object (publicAPI+model) with vtkImageReslice characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIImageResliceInitialValuesNo(default: {})

getAutoCropOutput

Returns

TypeDescription

getAutoCroppedOutputBounds

Compute the bounds required to ensure that none of the data will be cropped

ArgumentTypeRequiredDescription
inputYes

Returns

TypeDescription

getBackgroundColor

Returns

TypeDescription

getBorder

Returns

TypeDescription

getCompositeFunc

Returns the right composition function

ArgumentTypeRequiredDescription
slabModeYes
slabTrapezoidIntegrationYes

Returns

TypeDescription

getConversionFunc

Setup the conversion function and return the right one

ArgumentTypeRequiredDescription
inputTypeYes
dataTypeYes
scalarShiftYes
scalarScaleYes
forceClampingYes

Returns

TypeDescription
publicAPI.convert or publicAPI.clamp

getDataTypeMinMax

The min and max of each data type Defaults to a range of 0 to 255

ArgumentTypeRequiredDescription
dataTypeYes

Returns

TypeDescription

getIndexMatrix

The transform matrix supplied by the user converts output coordinates to input coordinates. To speed up the pixel lookup, the following function provides a matrix which converts output pixel indices to input pixel indices. This will also concatenate the ResliceAxes and the ResliceTransform if possible (if the ResliceTransform is a 4x4 matrix transform). If it does, this->OptimizedTransform will be set to nullptr, otherwise this->OptimizedTransform will be equal to this->ResliceTransform.

ArgumentTypeRequiredDescription
inputvtkImageDataYes
outputvtkImageDataYes

Returns

TypeDescription

getInterpolationMode

Returns

TypeDescription

getMirror

Returns

TypeDescription

getOutputDimensionality

Returns

TypeDescription

getOutputDirection

Returns

TypeDescription

getOutputExtent

Returns

TypeDescription

getOutputOrigin

Returns

TypeDescription

getOutputScalarType

Returns

TypeDescription

getOutputSpacing

Returns

TypeDescription

getResliceAxes

Returns

TypeDescription

getResliceTransform

Returns

TypeDescription

getScalarScale

Returns

TypeDescription

getScalarShift

Returns

TypeDescription

getSetPixelsFunc

Returns the right function used to copy the pixels

ArgumentTypeRequiredDescription
dataTypeYes
dataSizeYes
numscalarsYes
dataPtrYes

Returns

TypeDescription
publicAPI.set or publicAPI.set1

getSlabMode

Returns

TypeDescription

getSlabNumberOfSlices

Returns

TypeDescription

getSlabSliceSpacingFraction

Returns

TypeDescription

getSlabTrapezoidIntegration

Returns

TypeDescription

getTransformInputSampling

Returns

TypeDescription

getWrap

Returns

TypeDescription

isIdentityMatrix

ArgumentTypeRequiredDescription
matrixYes

Returns

TypeDescription

isPermutationMatrix

A permutation matrix is the identity matrix with the colomn (or rows) shuffled

ArgumentTypeRequiredDescription
matrixYes

Returns

TypeDescription

isPerspectiveMatrix

ArgumentTypeRequiredDescription
matrixYes

Returns

TypeDescription

newInstance

Method used to create a new instance of vtkImageReslice

ArgumentTypeRequiredDescription
initialValuesIImageResliceInitialValuesNofor pre-setting some of its content

requestData

ArgumentTypeRequiredDescription
inDataYes
outDataYes

rescaleScalars

ArgumentTypeRequiredDescription
floatDataYes
componentsYes
nYes
scalarShiftYes
scalarScaleYes

Returns

TypeDescription

set

Copy the numscalars * n first elements from an array to another

ArgumentTypeRequiredDescription
outPtrYes
inPtrYes
numscalarsYes
nYes

Returns

TypeDescription
The number of copied elements

set1

Fill the n first elements of the output array with the very first element of the input array

ArgumentTypeRequiredDescription
outPtrYes
inPtrYes
numscalarsYes
nYes

Returns

TypeDescription
The number of elements set in the output array

setAutoCropOutput

Turn this on if you want to guarantee that the extent of the output will be large enough to ensure that none of the data will be cropped. Defaults to false.

ArgumentTypeRequiredDescription
autoCropOutputYes

Returns

TypeDescription

setBackgroundColor

Set the background color (for multi-component images). Defaults to full opaque black.

ArgumentTypeRequiredDescription
backgroundColorYes

Returns

TypeDescription

setBorder

Extend the apparent input border by a half voxel. This changes how interpolation is handled at the borders of the input image: if the center of an output voxel is beyond the edge of the input image, but is within a half voxel width of the edge (using the input voxel width), then the value of the output voxel is calculated as if the input's edge voxels were duplicated past the edges of the input. This has no effect if Mirror or Wrap are on. Defaults to true.

ArgumentTypeRequiredDescription
borderYes

Returns

TypeDescription

setInterpolationMode

Set interpolation mode. Only nearest neighbor is supported at the moment. Defaults to nearest neighbor.

ArgumentTypeRequiredDescription
interpolationModeYes

Returns

TypeDescription

setMirror

Turn on mirror-pad feature. This will override the wrap-pad. Defaults to false.

ArgumentTypeRequiredDescription
mirrorYes

Returns

TypeDescription

setOutputDimensionality

Force the dimensionality of the output to either 1, 2, 3 or 0. If the dimensionality is 2D, then the Z extent of the output is forced to (0,0) and the Z origin of the output is forced to 0.0 (i.e. the output extent is confined to the xy plane). If the dimensionality is 1D, the output extent is confined to the x axis. For 0D, the output extent consists of a single voxel at (0,0,0). Defaults to 3.

ArgumentTypeRequiredDescription
outputDimensionalityYes

Returns

TypeDescription

setOutputDirection

Set the direction for the output data. By default, the direction of the input data is passed to the output. But if SetOutputDirection() is used, then the image will be resliced according to the new output direction. Unlike SetResliceAxes(), this does not change the physical coordinate system for the image. Instead, it changes the orientation of the sampling grid while maintaining the same physical coordinate system. Defaults to null (automatically computed).

ArgumentTypeRequiredDescription
outputDirectionYes

Returns

TypeDescription

setOutputExtent

Set the extent for the output data. The default output extent is the input extent permuted through the ResliceAxes. Defaults to null (automatically computed).

ArgumentTypeRequiredDescription
outputExtentYes

Returns

TypeDescription

setOutputOrigin

Set the origin for the output data. The default output origin is the input origin permuted through the ResliceAxes. Defaults to null (automatically computed).

ArgumentTypeRequiredDescription
outputOriginYes

Returns

TypeDescription

setOutputScalarType

Set the scalar type of the output to be different from the input. The default value is null, which means that the input scalar type will be used to set the output scalar type. Otherwise, this must be set to one of the following types: VtkDataTypes.CHAR, VtkDataTypes.SIGNED_CHAR, VtkDataTypes.UNSIGNED_CHAR, VtkDataTypes.SHORT, VtkDataTypes.UNSIGNED_SHORT, VtkDataTypes.INT, VtkDataTypes.UNSIGNED_INT, VtkDataTypes.FLOAT or VtkDataTypes.DOUBLE. Other types are not permitted. If the output type is an integer type, the output will be rounded and clamped to the limits of the type.

See the documentation for vtkDataArray::getDataType() for additional data type settings. Defaults to null (automatically computed).

ArgumentTypeRequiredDescription
outputScalarTypeYes

Returns

TypeDescription

setOutputSpacing

Set the voxel spacing for the output data. The default output spacing is the input spacing permuted through the ResliceAxes. Defaults to null (automatically computed).

ArgumentTypeRequiredDescription
outputSpacingYes

Returns

TypeDescription

setResliceAxes

This method is used to set up the axes for the output voxels. The output Spacing, Origin, and Extent specify the locations of the voxels within the coordinate system defined by the axes. The ResliceAxes are used most often to permute the data, e.g. to extract ZY or XZ slices of a volume as 2D XY images. The first column of the matrix specifies the x-axis vector (the fourth element must be set to zero), the second column specifies the y-axis, and the third column the z-axis. The fourth column is the origin of the axes (the fourth element must be set to one).

ArgumentTypeRequiredDescription
resliceAxesYes

Returns

TypeDescription

setResliceTransform

Set a transform to be applied to the resampling grid that has been defined via the ResliceAxes and the output Origin, Spacing and Extent. Note that applying a transform to the resampling grid (which lies in the output coordinate system) is equivalent to applying the inverse of that transform to the input volume. Nonlinear transforms such as vtkGridTransform and vtkThinPlateSplineTransform can be used here. Defaults to undefined.

ArgumentTypeRequiredDescription
resliceTransformYes

Returns

TypeDescription

setScalarScale

Set multiplication factor to apply to all the output voxels. After a sample value has been interpolated from the input image, the equation u = (v + ScalarShift)*ScalarScale will be applied to it before it is written to the output image. The result will always be clamped to the limits of the output data type. Defaults to 1.

ArgumentTypeRequiredDescription
scalarScaleYes

Returns

TypeDescription

setScalarShift

Set a value to add to all the output voxels. After a sample value has been interpolated from the input image, the equation u = (v + ScalarShift)*ScalarScale will be applied to it before it is written to the output image. The result will always be clamped to the limits of the output data type. Defaults to 0.

ArgumentTypeRequiredDescription
scalarShiftYes

Returns

TypeDescription

setSlabMode

Set the slab mode, for generating thick slices. The default is SlabMode.MIN. If SetSlabNumberOfSlices(N) is called with N greater than one, then each output slice will actually be a composite of N slices. This method specifies the compositing mode to be used.

ArgumentTypeRequiredDescription
slabModeYes

Returns

TypeDescription

setSlabNumberOfSlices

Set the number of slices that will be combined to create the slab. Defaults to 1.

ArgumentTypeRequiredDescription
numberOfSlicesYes

Returns

TypeDescription

setSlabSliceSpacingFraction

The slab spacing as a fraction of the output slice spacing. When one of the various slab modes is chosen, each output slice is produced by generating several "temporary" output slices and then combining them according to the slab mode. By default, the spacing between these temporary slices is the Z component of the OutputSpacing. This method sets the spacing between these temporary slices to be a fraction of the output spacing. Defaults to 1.

ArgumentTypeRequiredDescription
slabSliceSpacingFractionYes

Returns

TypeDescription

setSlabTrapezoidIntegration

Use trapezoid integration for slab computation. All this does is weigh the first and last slices by half when doing sum and mean. It is off by default. Defaults to false.

ArgumentTypeRequiredDescription
slabTrapezoidIntegrationYes

Returns

TypeDescription

setTransformInputSampling

Specify whether to transform the spacing, origin and extent of the Input (or the InformationInput) according to the direction cosines and origin of the ResliceAxes before applying them as the default output spacing, origin and extent. Defaults to false.

ArgumentTypeRequiredDescription
transformInputSamplingYes

Returns

TypeDescription

setWrap

Turn on wrap-pad feature. Defaults to false.

ArgumentTypeRequiredDescription
wrapYes

Returns

TypeDescription

vtkImageResliceExecute

Main filter logic

ArgumentTypeRequiredDescription
inputYes
outputYes

Returns

TypeDescription