00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00083 #ifndef __vtkImageReslice_h
00084 #define __vtkImageReslice_h
00085
00086
00087 #include "vtkImageToImageFilter.h"
00088 #include "vtkAbstractTransform.h"
00089 #include "vtkMatrix4x4.h"
00090 #include "vtkImageStencilData.h"
00091
00092
00093 #define VTK_RESLICE_NEAREST 0
00094 #define VTK_RESLICE_LINEAR 1
00095 #define VTK_RESLICE_CUBIC 3
00096
00097 class VTK_IMAGING_EXPORT vtkImageReslice : public vtkImageToImageFilter
00098 {
00099 public:
00100 static vtkImageReslice *New();
00101 vtkTypeMacro(vtkImageReslice, vtkImageToImageFilter);
00102
00103 virtual void PrintSelf(ostream& os, vtkIndent indent);
00104
00106
00118 vtkSetObjectMacro(ResliceAxes, vtkMatrix4x4);
00119 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
00121
00123
00127 void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
00128 double y0, double y1, double y2,
00129 double z0, double z1, double z2);
00130 void SetResliceAxesDirectionCosines(const double x[3],
00131 const double y[3],
00132 const double z[3]) {
00133 this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
00134 y[0], y[1], y[2],
00135 z[0], z[1], z[2]); };
00136 void SetResliceAxesDirectionCosines(const double xyz[9]) {
00137 this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
00138 xyz[3], xyz[4], xyz[5],
00139 xyz[6], xyz[7], xyz[8]); };
00140 void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
00141 void GetResliceAxesDirectionCosines(double xyz[9]) {
00142 this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
00143 double *GetResliceAxesDirectionCosines() {
00144 this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
00145 return this->ResliceAxesDirectionCosines; };
00147
00149
00152 void SetResliceAxesOrigin(double x, double y, double z);
00153 void SetResliceAxesOrigin(const double xyz[3]) {
00154 this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
00155 void GetResliceAxesOrigin(double xyz[3]);
00156 double *GetResliceAxesOrigin() {
00157 this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
00158 return this->ResliceAxesOrigin; };
00160
00162
00169 vtkSetObjectMacro(ResliceTransform, vtkAbstractTransform);
00170 vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
00172
00174
00180 vtkSetObjectMacro(InformationInput, vtkImageData);
00181 vtkGetObjectMacro(InformationInput, vtkImageData);
00183
00185
00189 vtkSetMacro(TransformInputSampling, int);
00190 vtkBooleanMacro(TransformInputSampling, int);
00191 vtkGetMacro(TransformInputSampling, int);
00193
00195
00197 vtkSetMacro(AutoCropOutput, int);
00198 vtkBooleanMacro(AutoCropOutput, int);
00199 vtkGetMacro(AutoCropOutput, int);
00201
00203
00204 vtkSetMacro(Wrap, int);
00205 vtkGetMacro(Wrap, int);
00206 vtkBooleanMacro(Wrap, int);
00208
00210
00212 vtkSetMacro(Mirror, int);
00213 vtkGetMacro(Mirror, int);
00214 vtkBooleanMacro(Mirror, int);
00216
00218
00219 vtkSetMacro(InterpolationMode, int);
00220 vtkGetMacro(InterpolationMode, int);
00221 void SetInterpolationModeToNearestNeighbor() {
00222 this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
00223 void SetInterpolationModeToLinear() {
00224 this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
00225 void SetInterpolationModeToCubic() {
00226 this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
00227 const char *GetInterpolationModeAsString();
00229
00231
00233 vtkSetMacro(Optimization, int);
00234 vtkGetMacro(Optimization, int);
00235 vtkBooleanMacro(Optimization, int);
00237
00239
00240 vtkSetVector4Macro(BackgroundColor, float);
00241 vtkGetVector4Macro(BackgroundColor, float);
00243
00245
00246 void SetBackgroundLevel(float v) { this->SetBackgroundColor(v,v,v,v); };
00247 float GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00249
00251
00253 vtkSetVector3Macro(OutputSpacing, float);
00254 vtkGetVector3Macro(OutputSpacing, float);
00255 void SetOutputSpacingToDefault() {
00256 this->SetOutputSpacing(VTK_FLOAT_MAX, VTK_FLOAT_MAX, VTK_FLOAT_MAX); };
00258
00260
00262 vtkSetVector3Macro(OutputOrigin, float);
00263 vtkGetVector3Macro(OutputOrigin, float);
00264 void SetOutputOriginToDefault() {
00265 this->SetOutputOrigin(VTK_FLOAT_MAX, VTK_FLOAT_MAX, VTK_FLOAT_MAX); };
00267
00269
00271 vtkSetVector6Macro(OutputExtent, int);
00272 vtkGetVector6Macro(OutputExtent, int);
00273 void SetOutputExtentToDefault() {
00274 this->SetOutputExtent(VTK_INT_MIN, VTK_INT_MAX,
00275 VTK_INT_MIN, VTK_INT_MAX,
00276 VTK_INT_MIN, VTK_INT_MAX); };
00278
00280
00286 vtkSetMacro(OutputDimensionality, int);
00287 vtkGetMacro(OutputDimensionality, int);
00289
00292 unsigned long int GetMTime();
00293
00295
00300 void SetInterpolate(int t) {
00301 if (t && !this->GetInterpolate()) {
00302 this->SetInterpolationModeToLinear(); }
00303 else if (!t && this->GetInterpolate()) {
00304 this->SetInterpolationModeToNearestNeighbor(); } };
00305 void InterpolateOn() {
00306 this->SetInterpolate(1); };
00307 void InterpolateOff() {
00308 this->SetInterpolate(0); };
00309 int GetInterpolate() {
00310 return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00312
00314
00317 void SetStencil(vtkImageStencilData *stencil);
00318 vtkImageStencilData *GetStencil();
00320
00321 protected:
00322 vtkImageReslice();
00323 ~vtkImageReslice();
00324
00325 vtkMatrix4x4 *ResliceAxes;
00326 double ResliceAxesDirectionCosines[9];
00327 double ResliceAxesOrigin[3];
00328 vtkAbstractTransform *ResliceTransform;
00329 vtkImageData *InformationInput;
00330 int Wrap;
00331 int Mirror;
00332 int InterpolationMode;
00333 int Optimization;
00334 float BackgroundColor[4];
00335 float OutputOrigin[3];
00336 float OutputSpacing[3];
00337 int OutputExtent[6];
00338 int OutputDimensionality;
00339 int TransformInputSampling;
00340 int AutoCropOutput;
00341
00342 vtkMatrix4x4 *IndexMatrix;
00343 vtkAbstractTransform *OptimizedTransform;
00344
00345 void GetAutoCroppedOutputBounds(vtkImageData *input, float bounds[6]);
00346 void ExecuteInformation(vtkImageData *input, vtkImageData *output);
00347 void ExecuteInformation() {
00348 this->vtkImageToImageFilter::ExecuteInformation(); };
00349 void ComputeInputUpdateExtents(vtkDataObject *output);
00350 void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
00351 void ThreadedExecute(vtkImageData *inData, vtkImageData *outData,
00352 int ext[6], int id);
00353
00354 vtkMatrix4x4 *GetIndexMatrix();
00355 vtkAbstractTransform *GetOptimizedTransform() {
00356 return this->OptimizedTransform; };
00357 void OptimizedComputeInputUpdateExtent(int inExt[6], int outExt[6]);
00358 void OptimizedThreadedExecute(vtkImageData *inData, vtkImageData *outData,
00359 int ext[6], int id);
00360 private:
00361 vtkImageReslice(const vtkImageReslice&);
00362 void operator=(const vtkImageReslice&);
00363 };
00364
00365
00366 inline const char *vtkImageReslice::GetInterpolationModeAsString()
00367 {
00368 switch (this->InterpolationMode)
00369 {
00370 case VTK_RESLICE_NEAREST:
00371 return "NearestNeighbor";
00372 case VTK_RESLICE_LINEAR:
00373 return "Linear";
00374 case VTK_RESLICE_CUBIC:
00375 return "Cubic";
00376 default:
00377 return "";
00378 }
00379 }
00380
00381 #endif
00382
00383
00384
00385
00386