FreeMat

- Main Page
- Related Pages

vtkImageReslice

Section: Visualization Toolkit Imaging Classes

# Usage

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) Resampling of one data set to match the voxel sampling of a second data set via the SetInformationInput() method, e.g. for the purpose of comparing two images or combining two images. A transformation, either linear or nonlinear, can be applied at the same time via the SetResliceTransform method if the two images are not in the same coordinate space.

3) Extraction of slices from an image volume. The most convenient way to do this is to use SetResliceAxesDirectionCosines() to specify the orientation of the slice. The direction cosines give the x, y, and z axes for the output volume. The method SetOutputDimensionality(2) is used to specify that want to output a slice rather than a volume. The SetResliceAxesOrigin() command is used to provide an (x,y,z) point that the slice will pass through. 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.

To create an instance of class vtkImageReslice, simply invoke its constructor as follows

      obj = vtkImageReslice

# Methods

The class vtkImageReslice has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkImageReslice class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkImageReslice = obj.NewInstance ()`
- `vtkImageReslice = obj.SafeDownCast (vtkObject o)`

- `obj.SetResliceAxes (vtkMatrix4x4 )` - 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).

  An alternative to SetResliceAxes() is to use SetResliceAxesDirectionCosines() to set the directions of the axes and SetResliceAxesOrigin() to set the origin of the axes.

- `vtkMatrix4x4 = obj.GetResliceAxes ()` - 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).

  An alternative to SetResliceAxes() is to use SetResliceAxesDirectionCosines() to set the directions of the axes and SetResliceAxesOrigin() to set the origin of the axes.

- `obj.SetResliceAxesDirectionCosines (double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)` - Specify the direction cosines for the ResliceAxes (i.e. the first three elements of each of the first three columns of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create a new matrix if none exists.
- `obj.SetResliceAxesDirectionCosines (double x[3], double y[3], double z[3])` - Specify the direction cosines for the ResliceAxes (i.e. the first three elements of each of the first three columns of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create a new matrix if none exists.
- `obj.SetResliceAxesDirectionCosines (double xyz[9])` - Specify the direction cosines for the ResliceAxes (i.e. the first three elements of each of the first three columns of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create a new matrix if none exists.
- `obj.GetResliceAxesDirectionCosines (double x[3], double y[3], double z[3])` - Specify the direction cosines for the ResliceAxes (i.e. the first three elements of each of the first three columns of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create a new matrix if none exists.
- `obj.GetResliceAxesDirectionCosines (double xyz[9])` - Specify the direction cosines for the ResliceAxes (i.e. the first three elements of each of the first three columns of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create a new matrix if none exists.
- `double = obj.GetResliceAxesDirectionCosines ()` - Specify the direction cosines for the ResliceAxes (i.e. the first three elements of each of the first three columns of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create a new matrix if none exists.
- `obj.SetResliceAxesOrigin (double x, double y, double z)` - Specify the origin for the ResliceAxes (i.e. the first three elements of the final column of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create new matrix if none exists.
- `obj.SetResliceAxesOrigin (double xyz[3])` - Specify the origin for the ResliceAxes (i.e. the first three elements of the final column of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create new matrix if none exists.
- `obj.GetResliceAxesOrigin (double xyz[3])` - Specify the origin for the ResliceAxes (i.e. the first three elements of the final column of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create new matrix if none exists.
- `double = obj.GetResliceAxesOrigin ()` - Specify the origin for the ResliceAxes (i.e. the first three elements of the final column of the ResliceAxes matrix). This will modify the current ResliceAxes matrix, or create new matrix if none exists.
- `obj.SetResliceTransform (vtkAbstractTransform )` - 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.
- `vtkAbstractTransform = obj.GetResliceTransform ()` - 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.
- `obj.SetInformationInput (vtkImageData )` - Set a vtkImageData from which the default Spacing, Origin, and WholeExtent of the output will be copied. The spacing, origin, and extent will be permuted according to the ResliceAxes. Any values set via SetOutputSpacing, SetOutputOrigin, and SetOutputExtent will override these values. By default, the Spacing, Origin, and WholeExtent of the Input are used.
- `vtkImageData = obj.GetInformationInput ()` - Set a vtkImageData from which the default Spacing, Origin, and WholeExtent of the output will be copied. The spacing, origin, and extent will be permuted according to the ResliceAxes. Any values set via SetOutputSpacing, SetOutputOrigin, and SetOutputExtent will override these values. By default, the Spacing, Origin, and WholeExtent of the Input are used.
- `obj.SetTransformInputSampling (int )` - 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 (default: On).
- `obj.TransformInputSamplingOn ()` - 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 (default: On).
- `obj.TransformInputSamplingOff ()` - 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 (default: On).
- `int = obj.GetTransformInputSampling ()` - 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 (default: On).
- `obj.SetAutoCropOutput (int )` - 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 (default: Off).
- `obj.AutoCropOutputOn ()` - 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 (default: Off).
- `obj.AutoCropOutputOff ()` - 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 (default: Off).
- `int = obj.GetAutoCropOutput ()` - 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 (default: Off).
- `obj.SetWrap (int )` - Turn on wrap-pad feature (default: Off).
- `int = obj.GetWrap ()` - Turn on wrap-pad feature (default: Off).
- `obj.WrapOn ()` - Turn on wrap-pad feature (default: Off).
- `obj.WrapOff ()` - Turn on wrap-pad feature (default: Off).
- `obj.SetMirror (int )` - Turn on mirror-pad feature (default: Off). This will override the wrap-pad.
- `int = obj.GetMirror ()` - Turn on mirror-pad feature (default: Off). This will override the wrap-pad.
- `obj.MirrorOn ()` - Turn on mirror-pad feature (default: Off). This will override the wrap-pad.
- `obj.MirrorOff ()` - Turn on mirror-pad feature (default: Off). This will override the wrap-pad.
- `obj.SetBorder (int )` - Extend the apparent input border by a half voxel (default: On). 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.
- `int = obj.GetBorder ()` - Extend the apparent input border by a half voxel (default: On). 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.
- `obj.BorderOn ()` - Extend the apparent input border by a half voxel (default: On). 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.
- `obj.BorderOff ()` - Extend the apparent input border by a half voxel (default: On). 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.
- `obj.SetInterpolationMode (int )` - Set interpolation mode (default: nearest neighbor).
- `int = obj.GetInterpolationModeMinValue ()` - Set interpolation mode (default: nearest neighbor).
- `int = obj.GetInterpolationModeMaxValue ()` - Set interpolation mode (default: nearest neighbor).
- `int = obj.GetInterpolationMode ()` - Set interpolation mode (default: nearest neighbor).
- `obj.SetInterpolationModeToNearestNeighbor ()` - Set interpolation mode (default: nearest neighbor).
- `obj.SetInterpolationModeToLinear ()` - Set interpolation mode (default: nearest neighbor).
- `obj.SetInterpolationModeToCubic ()` - Set interpolation mode (default: nearest neighbor).
- `string = obj.GetInterpolationModeAsString ()` - Set interpolation mode (default: nearest neighbor).
- `obj.SetOptimization (int )` - Turn on and off optimizations (default on, they should only be turned off for testing purposes).
- `int = obj.GetOptimization ()` - Turn on and off optimizations (default on, they should only be turned off for testing purposes).
- `obj.OptimizationOn ()` - Turn on and off optimizations (default on, they should only be turned off for testing purposes).
- `obj.OptimizationOff ()` - Turn on and off optimizations (default on, they should only be turned off for testing purposes).
- `obj.SetBackgroundColor (double , double , double , double )` - Set the background color (for multi-component images).
- `obj.SetBackgroundColor (double a[4])` - Set the background color (for multi-component images).
- `double = obj. GetBackgroundColor ()` - Set the background color (for multi-component images).
- `obj.SetBackgroundLevel (double v)` - Set background grey level (for single-component images).
- `double = obj.GetBackgroundLevel ()` - Set background grey level (for single-component images).
- `obj.SetOutputSpacing (double , double , double )` - Set the voxel spacing for the output data. The default output spacing is the input spacing permuted through the ResliceAxes.
- `obj.SetOutputSpacing (double a[3])` - Set the voxel spacing for the output data. The default output spacing is the input spacing permuted through the ResliceAxes.
- `double = obj. GetOutputSpacing ()` - Set the voxel spacing for the output data. The default output spacing is the input spacing permuted through the ResliceAxes.
- `obj.SetOutputSpacingToDefault ()` - Set the voxel spacing for the output data. The default output spacing is the input spacing permuted through the ResliceAxes.
- `obj.SetOutputOrigin (double , double , double )` - Set the origin for the output data. The default output origin is the input origin permuted through the ResliceAxes.
- `obj.SetOutputOrigin (double a[3])` - Set the origin for the output data. The default output origin is the input origin permuted through the ResliceAxes.
- `double = obj. GetOutputOrigin ()` - Set the origin for the output data. The default output origin is the input origin permuted through the ResliceAxes.
- `obj.SetOutputOriginToDefault ()` - Set the origin for the output data. The default output origin is the input origin permuted through the ResliceAxes.
- `obj.SetOutputExtent (int , int , int , int , int , int )` - Set the extent for the output data. The default output extent is the input extent permuted through the ResliceAxes.
- `obj.SetOutputExtent (int a[6])` - Set the extent for the output data. The default output extent is the input extent permuted through the ResliceAxes.
- `int = obj. GetOutputExtent ()` - Set the extent for the output data. The default output extent is the input extent permuted through the ResliceAxes.
- `obj.SetOutputExtentToDefault ()` - Set the extent for the output data. The default output extent is the input extent permuted through the ResliceAxes.
- `obj.SetOutputDimensionality (int )` - Force the dimensionality of the output to either 1, 2, 3 or 0 (default: 3). 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).
- `int = obj.GetOutputDimensionality ()` - Force the dimensionality of the output to either 1, 2, 3 or 0 (default: 3). 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).
- `long = obj.GetMTime ()` - When determining the modified time of the filter, this check the modified time of the transform and matrix.
- `obj.ReportReferences (vtkGarbageCollector )` - Report object referenced by instances of this class.
- `obj.SetInterpolate (int t)` - Convenient methods for switching between nearest-neighbor and linear interpolation. InterpolateOn() is equivalent to SetInterpolationModeToLinear() and InterpolateOff() is equivalent to SetInterpolationModeToNearestNeighbor(). You should not use these methods if you use the SetInterpolationMode methods.
- `obj.InterpolateOn ()` - Convenient methods for switching between nearest-neighbor and linear interpolation. InterpolateOn() is equivalent to SetInterpolationModeToLinear() and InterpolateOff() is equivalent to SetInterpolationModeToNearestNeighbor(). You should not use these methods if you use the SetInterpolationMode methods.
- `obj.InterpolateOff ()` - Convenient methods for switching between nearest-neighbor and linear interpolation. InterpolateOn() is equivalent to SetInterpolationModeToLinear() and InterpolateOff() is equivalent to SetInterpolationModeToNearestNeighbor(). You should not use these methods if you use the SetInterpolationMode methods.
- `int = obj.GetInterpolate ()` - Convenient methods for switching between nearest-neighbor and linear interpolation. InterpolateOn() is equivalent to SetInterpolationModeToLinear() and InterpolateOff() is equivalent to SetInterpolationModeToNearestNeighbor(). You should not use these methods if you use the SetInterpolationMode methods.
- `obj.SetStencil (vtkImageStencilData stencil)` - Use a stencil to limit the calculations to a specific region of the output. Portions of the output that are 'outside' the stencil will be cleared to the background color.
- `vtkImageStencilData = obj.GetStencil ()` - Use a stencil to limit the calculations to a specific region of the output. Portions of the output that are 'outside' the stencil will be cleared to the background color.