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:
- 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.
- 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
| Argument | Type | Required | Description |
|---|---|---|---|
newTrans | Yes | ||
inPoint | Yes | ||
inOrigin | Yes | ||
inInvSpacing | Yes |
Returns
| Type | Description |
|---|---|
canUseNearestNeighbor
| Argument | Type | Required | Description |
|---|---|---|---|
matrix | Yes | ||
outExt | Yes |
Returns
| Type | Description |
|---|---|
clamp
Internal function uses vtkInterpolationMathClamp on numscalars * n elements
| Argument | Type | Required | Description |
|---|---|---|---|
outPtr | Yes | ||
inPtr | Yes | ||
numscalars | Yes | ||
n | Yes | ||
min | Yes | ||
max | Yes |
Returns
| Type | Description |
|---|---|
| The number of elements processed |
convert
Internal function uses Math.round on numscalars * n elements
| Argument | Type | Required | Description |
|---|---|---|---|
outPtr | Yes | ||
inPtr | Yes | ||
numscalars | Yes | ||
n | Yes |
Returns
| Type | Description |
|---|---|
| The number of elements processed |
extend
Method used to decorate a given object (publicAPI+model) with vtkImageReslice characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IImageResliceInitialValues | No | (default: {}) |
getAutoCropOutput
Returns
| Type | Description |
|---|---|
getAutoCroppedOutputBounds
Compute the bounds required to ensure that none of the data will be cropped
| Argument | Type | Required | Description |
|---|---|---|---|
input | Yes |
Returns
| Type | Description |
|---|---|
getBackgroundColor
Returns
| Type | Description |
|---|---|
getBorder
Returns
| Type | Description |
|---|---|
getCompositeFunc
Returns the right composition function
| Argument | Type | Required | Description |
|---|---|---|---|
slabMode | Yes | ||
slabTrapezoidIntegration | Yes |
Returns
| Type | Description |
|---|---|
getConversionFunc
Setup the conversion function and return the right one
| Argument | Type | Required | Description |
|---|---|---|---|
inputType | Yes | ||
dataType | Yes | ||
scalarShift | Yes | ||
scalarScale | Yes | ||
forceClamping | Yes |
Returns
| Type | Description |
|---|---|
| publicAPI.convert or publicAPI.clamp |
getDataTypeMinMax
The min and max of each data type Defaults to a range of 0 to 255
| Argument | Type | Required | Description |
|---|---|---|---|
dataType | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
input | vtkImageData | Yes | |
output | vtkImageData | Yes |
Returns
| Type | Description |
|---|---|
getInterpolationMode
Returns
| Type | Description |
|---|---|
getMirror
Returns
| Type | Description |
|---|---|
getOutputDimensionality
Returns
| Type | Description |
|---|---|
getOutputDirection
Returns
| Type | Description |
|---|---|
getOutputExtent
Returns
| Type | Description |
|---|---|
getOutputOrigin
Returns
| Type | Description |
|---|---|
getOutputScalarType
Returns
| Type | Description |
|---|---|
getOutputSpacing
Returns
| Type | Description |
|---|---|
getResliceAxes
Returns
| Type | Description |
|---|---|
getResliceTransform
Returns
| Type | Description |
|---|---|
getScalarScale
Returns
| Type | Description |
|---|---|
getScalarShift
Returns
| Type | Description |
|---|---|
getSetPixelsFunc
Returns the right function used to copy the pixels
| Argument | Type | Required | Description |
|---|---|---|---|
dataType | Yes | ||
dataSize | Yes | ||
numscalars | Yes | ||
dataPtr | Yes |
Returns
| Type | Description |
|---|---|
| publicAPI.set or publicAPI.set1 |
getSlabMode
Returns
| Type | Description |
|---|---|
getSlabNumberOfSlices
Returns
| Type | Description |
|---|---|
getSlabSliceSpacingFraction
Returns
| Type | Description |
|---|---|
getSlabTrapezoidIntegration
Returns
| Type | Description |
|---|---|
getTransformInputSampling
Returns
| Type | Description |
|---|---|
getWrap
Returns
| Type | Description |
|---|---|
isIdentityMatrix
| Argument | Type | Required | Description |
|---|---|---|---|
matrix | Yes |
Returns
| Type | Description |
|---|---|
isPermutationMatrix
A permutation matrix is the identity matrix with the colomn (or rows) shuffled
| Argument | Type | Required | Description |
|---|---|---|---|
matrix | Yes |
Returns
| Type | Description |
|---|---|
isPerspectiveMatrix
| Argument | Type | Required | Description |
|---|---|---|---|
matrix | Yes |
Returns
| Type | Description |
|---|---|
newInstance
Method used to create a new instance of vtkImageReslice
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IImageResliceInitialValues | No | for pre-setting some of its content |
requestData
| Argument | Type | Required | Description |
|---|---|---|---|
inData | Yes | ||
outData | Yes |
rescaleScalars
| Argument | Type | Required | Description |
|---|---|---|---|
floatData | Yes | ||
components | Yes | ||
n | Yes | ||
scalarShift | Yes | ||
scalarScale | Yes |
Returns
| Type | Description |
|---|---|
set
Copy the numscalars * n first elements from an array to another
| Argument | Type | Required | Description |
|---|---|---|---|
outPtr | Yes | ||
inPtr | Yes | ||
numscalars | Yes | ||
n | Yes |
Returns
| Type | Description |
|---|---|
| The number of copied elements |
set1
Fill the n first elements of the output array with the very first element of the input array
| Argument | Type | Required | Description |
|---|---|---|---|
outPtr | Yes | ||
inPtr | Yes | ||
numscalars | Yes | ||
n | Yes |
Returns
| Type | Description |
|---|---|
| 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.
| Argument | Type | Required | Description |
|---|---|---|---|
autoCropOutput | Yes |
Returns
| Type | Description |
|---|---|
setBackgroundColor
Set the background color (for multi-component images). Defaults to full opaque black.
| Argument | Type | Required | Description |
|---|---|---|---|
backgroundColor | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
border | Yes |
Returns
| Type | Description |
|---|---|
setInterpolationMode
Set interpolation mode. Only nearest neighbor is supported at the moment. Defaults to nearest neighbor.
| Argument | Type | Required | Description |
|---|---|---|---|
interpolationMode | Yes |
Returns
| Type | Description |
|---|---|
setMirror
Turn on mirror-pad feature. This will override the wrap-pad. Defaults to false.
| Argument | Type | Required | Description |
|---|---|---|---|
mirror | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
outputDimensionality | Yes |
Returns
| Type | Description |
|---|---|
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).
| Argument | Type | Required | Description |
|---|---|---|---|
outputDirection | Yes |
Returns
| Type | Description |
|---|---|
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).
| Argument | Type | Required | Description |
|---|---|---|---|
outputExtent | Yes |
Returns
| Type | Description |
|---|---|
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).
| Argument | Type | Required | Description |
|---|---|---|---|
outputOrigin | Yes |
Returns
| Type | Description |
|---|---|
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).
| Argument | Type | Required | Description |
|---|---|---|---|
outputScalarType | Yes |
Returns
| Type | Description |
|---|---|
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).
| Argument | Type | Required | Description |
|---|---|---|---|
outputSpacing | Yes |
Returns
| Type | Description |
|---|---|
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).
| Argument | Type | Required | Description |
|---|---|---|---|
resliceAxes | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
resliceTransform | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
scalarScale | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
scalarShift | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
slabMode | Yes |
Returns
| Type | Description |
|---|---|
setSlabNumberOfSlices
Set the number of slices that will be combined to create the slab. Defaults to 1.
| Argument | Type | Required | Description |
|---|---|---|---|
numberOfSlices | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
slabSliceSpacingFraction | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
slabTrapezoidIntegration | Yes |
Returns
| Type | Description |
|---|---|
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.
| Argument | Type | Required | Description |
|---|---|---|---|
transformInputSampling | Yes |
Returns
| Type | Description |
|---|---|
setWrap
Turn on wrap-pad feature. Defaults to false.
| Argument | Type | Required | Description |
|---|---|---|---|
wrap | Yes |
Returns
| Type | Description |
|---|---|
vtkImageResliceExecute
Main filter logic
| Argument | Type | Required | Description |
|---|---|---|---|
input | Yes | ||
output | Yes |
Returns
| Type | Description |
|---|---|