/usr/include/vtk-5.10/vtkImageReslice.h is in libvtk5-dev 5.10.1+dfsg-2.1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkImageReslice.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkImageReslice - Reslices a volume along a new set of axes.
// .SECTION Description
// 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:
// <p>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.
// <p>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.
// <p>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.
// .SECTION Caveats
// This filter is very inefficient if the output X dimension is 1.
// .SECTION see also
// vtkAbstractTransform vtkMatrix4x4
#ifndef __vtkImageReslice_h
#define __vtkImageReslice_h
#include "vtkThreadedImageAlgorithm.h"
// interpolation mode constants
#define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
#define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
#define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
class vtkImageData;
class vtkAbstractTransform;
class vtkMatrix4x4;
class vtkImageStencilData;
class vtkScalarsToColors;
class vtkAbstractImageInterpolator;
class VTK_IMAGING_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
{
public:
static vtkImageReslice *New();
vtkTypeMacro(vtkImageReslice, vtkThreadedImageAlgorithm);
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// 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.
// <p>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).
// <p>An alternative to SetResliceAxes() is to use
// SetResliceAxesDirectionCosines() to set the directions of the
// axes and SetResliceAxesOrigin() to set the origin of the axes.
virtual void SetResliceAxes(vtkMatrix4x4*);
vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
// Description:
// 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.
void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
double y0, double y1, double y2,
double z0, double z1, double z2);
void SetResliceAxesDirectionCosines(const double x[3],
const double y[3],
const double z[3]) {
this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
y[0], y[1], y[2],
z[0], z[1], z[2]); };
void SetResliceAxesDirectionCosines(const double xyz[9]) {
this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
xyz[3], xyz[4], xyz[5],
xyz[6], xyz[7], xyz[8]); };
void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
void GetResliceAxesDirectionCosines(double xyz[9]) {
this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
double *GetResliceAxesDirectionCosines() {
this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
return this->ResliceAxesDirectionCosines; };
// Description:
// 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.
void SetResliceAxesOrigin(double x, double y, double z);
void SetResliceAxesOrigin(const double xyz[3]) {
this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
void GetResliceAxesOrigin(double xyz[3]);
double *GetResliceAxesOrigin() {
this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
return this->ResliceAxesOrigin; };
// Description:
// 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.
virtual void SetResliceTransform(vtkAbstractTransform*);
vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
// Description:
// 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.
virtual void SetInformationInput(vtkImageData*);
vtkGetObjectMacro(InformationInput, vtkImageData);
// Description:
// 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).
vtkSetMacro(TransformInputSampling, int);
vtkBooleanMacro(TransformInputSampling, int);
vtkGetMacro(TransformInputSampling, int);
// Description:
// 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).
vtkSetMacro(AutoCropOutput, int);
vtkBooleanMacro(AutoCropOutput, int);
vtkGetMacro(AutoCropOutput, int);
// Description:
// Turn on wrap-pad feature (default: Off).
vtkSetMacro(Wrap, int);
vtkGetMacro(Wrap, int);
vtkBooleanMacro(Wrap, int);
// Description:
// Turn on mirror-pad feature (default: Off).
// This will override the wrap-pad.
vtkSetMacro(Mirror, int);
vtkGetMacro(Mirror, int);
vtkBooleanMacro(Mirror, int);
// Description:
// 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.
vtkSetMacro(Border, int);
vtkGetMacro(Border, int);
vtkBooleanMacro(Border, int);
// Description:
// Set interpolation mode (default: nearest neighbor).
vtkSetClampMacro(InterpolationMode, int,
VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
vtkGetMacro(InterpolationMode, int);
void SetInterpolationModeToNearestNeighbor() {
this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
void SetInterpolationModeToLinear() {
this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
void SetInterpolationModeToCubic() {
this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
virtual const char *GetInterpolationModeAsString();
// Description:
// Set the interpolator to use. The default interpolator
// supports the Nearest, Linear, and Cubic interpolation modes.
virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
virtual vtkAbstractImageInterpolator *GetInterpolator();
// Description:
// Set the slab mode, the default is average.
vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
vtkGetMacro(SlabMode, int);
void SetSlabModeToMin() {
this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
void SetSlabModeToMax() {
this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
void SetSlabModeToMean() {
this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
void SetSlabModeToSum() {
this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
virtual const char *GetSlabModeAsString();
// Description:
// Set the number of slices that will be combined to create the slab.
vtkSetMacro(SlabNumberOfSlices, int);
vtkGetMacro(SlabNumberOfSlices, int);
// Description:
// 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.
vtkSetMacro(SlabTrapezoidIntegration, int);
vtkBooleanMacro(SlabTrapezoidIntegration, int);
vtkGetMacro(SlabTrapezoidIntegration, int);
// Description:
// Turn on and off optimizations (default on, they should only be
// turned off for testing purposes).
vtkSetMacro(Optimization, int);
vtkGetMacro(Optimization, int);
vtkBooleanMacro(Optimization, int);
// Description:
// Set the background color (for multi-component images).
vtkSetVector4Macro(BackgroundColor, double);
vtkGetVector4Macro(BackgroundColor, double);
// Description:
// Set background grey level (for single-component images).
void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
// Description:
// Set the voxel spacing for the output data. The default output
// spacing is the input spacing permuted through the ResliceAxes.
virtual void SetOutputSpacing(double x, double y, double z);
virtual void SetOutputSpacing(const double a[3]) {
this->SetOutputSpacing(a[0], a[1], a[2]); };
vtkGetVector3Macro(OutputSpacing, double);
void SetOutputSpacingToDefault();
// Description:
// Set the origin for the output data. The default output origin
// is the input origin permuted through the ResliceAxes.
virtual void SetOutputOrigin(double x, double y, double z);
virtual void SetOutputOrigin(const double a[3]) {
this->SetOutputOrigin(a[0], a[1], a[2]); };
vtkGetVector3Macro(OutputOrigin, double);
void SetOutputOriginToDefault();
// Description:
// Set the extent for the output data. The default output extent
// is the input extent permuted through the ResliceAxes.
virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
virtual void SetOutputExtent(const int a[6]) {
this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
vtkGetVector6Macro(OutputExtent, int);
void SetOutputExtentToDefault();
// Description:
// 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).
vtkSetMacro(OutputDimensionality, int);
vtkGetMacro(OutputDimensionality, int);
// Description:
// When determining the modified time of the filter,
// this check the modified time of the transform and matrix.
unsigned long int GetMTime();
// Description:
// Report object referenced by instances of this class.
virtual void ReportReferences(vtkGarbageCollector*);
// Description:
// 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.
void SetInterpolate(int t) {
if (t && !this->GetInterpolate()) {
this->SetInterpolationModeToLinear(); }
else if (!t && this->GetInterpolate()) {
this->SetInterpolationModeToNearestNeighbor(); } };
void InterpolateOn() {
this->SetInterpolate(1); };
void InterpolateOff() {
this->SetInterpolate(0); };
int GetInterpolate() {
return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
// Description:
// 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.
void SetStencil(vtkImageStencilData *stencil);
vtkImageStencilData *GetStencil();
// Description:
// Generate an output stencil that defines which pixels were
// interpolated and which pixels were out-of-bounds of the input.
vtkSetMacro(GenerateStencilOutput, int);
vtkGetMacro(GenerateStencilOutput, int);
vtkBooleanMacro(GenerateStencilOutput, int);
// Description:
// Get the output stencil.
vtkAlgorithmOutput *GetStencilOutputPort() {
return this->GetOutputPort(1); }
vtkImageStencilData *GetStencilOutput();
void SetStencilOutput(vtkImageStencilData *stencil);
protected:
vtkImageReslice();
~vtkImageReslice();
vtkMatrix4x4 *ResliceAxes;
double ResliceAxesDirectionCosines[9];
double ResliceAxesOrigin[3];
vtkAbstractTransform *ResliceTransform;
vtkAbstractImageInterpolator *Interpolator;
vtkImageData *InformationInput;
int Wrap;
int Mirror;
int Border;
int InterpolationMode;
int Optimization;
int SlabMode;
int SlabNumberOfSlices;
int SlabTrapezoidIntegration;
double BackgroundColor[4];
double OutputOrigin[3];
double OutputSpacing[3];
int OutputExtent[6];
int OutputScalarType;
int OutputDimensionality;
int TransformInputSampling;
int AutoCropOutput;
int HitInputExtent;
int UsePermuteExecute;
int ComputeOutputSpacing;
int ComputeOutputOrigin;
int ComputeOutputExtent;
int GenerateStencilOutput;
vtkMatrix4x4 *IndexMatrix;
vtkAbstractTransform *OptimizedTransform;
// Description:
// This should be set to 1 by derived classes that override the
// ConvertScalars method.
int HasConvertScalars;
// Description:
// This should be overridden by derived classes that operate on
// the interpolated data before it is placed in the output.
virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
// Description:
// This should be overridden by derived classes that operate on
// the interpolated data before it is placed in the output.
// The input data will usually be double or float (since the
// interpolation routines use floating-point) but it could be
// of any type. This method will be called from multiple threads,
// so it must be thread-safe in derived classes.
virtual void ConvertScalars(void *inPtr, void *outPtr,
int inputType, int inputNumComponents,
int count, int idX, int idY, int idZ,
int threadId);
void ConvertScalarsBase(void *inPtr, void *outPtr,
int inputType, int inputNumComponents,
int count, int idX, int idY, int idZ, int threadId) {
this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
count, idX, idY, idZ, threadId); }
void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
virtual void AllocateOutputData(vtkImageData *output, int *uExtent);
virtual vtkImageData *AllocateOutputData(vtkDataObject *);
virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual void ThreadedRequestData(vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector,
vtkImageData ***inData,
vtkImageData **outData, int ext[6], int id);
virtual int FillInputPortInformation(int port, vtkInformation *info);
virtual int FillOutputPortInformation(int port, vtkInformation *info);
vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
vtkInformation *outInfo);
vtkAbstractTransform *GetOptimizedTransform() {
return this->OptimizedTransform; };
private:
vtkImageReslice(const vtkImageReslice&); // Not implemented.
void operator=(const vtkImageReslice&); // Not implemented.
};
#endif
|