Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkOrientedImageDataResample.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
16  and was supported through the Applied Cancer Research Unit program of Cancer Care
17  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkOrientedImageDataResample_h
22 #define __vtkOrientedImageDataResample_h
23 
24 // Segmentation includes
25 #include "vtkSegmentationCoreConfigure.h"
26 
27 // VTK includes
28 #include "vtkObject.h"
29 
30 // std includes
31 #include <vector>
32 #include <cmath> // for fabs
33 
34 class vtkImageData;
35 class vtkMatrix4x4;
37 class vtkTransform;
38 class vtkAbstractTransform;
39 
42 class vtkSegmentationCore_EXPORT vtkOrientedImageDataResample : public vtkObject
43 {
44 public:
45  static vtkOrientedImageDataResample *New();
46  vtkTypeMacro(vtkOrientedImageDataResample,vtkObject);
47 
48  enum
49  {
52  OPERATION_MASKING
53  };
54 
62  static bool ResampleOrientedImageToReferenceGeometry(vtkOrientedImageData* inputImage, vtkMatrix4x4* referenceGeometryMatrix, vtkOrientedImageData* outputImage, bool linearInterpolation=false);
63 
73  static bool ResampleOrientedImageToReferenceOrientedImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* referenceImage, vtkOrientedImageData* outputImage, bool linearInterpolation=false, bool padImage=false, vtkAbstractTransform* inputImageTransform=nullptr, double backgroundValue=0);
74 
83  static void TransformOrientedImage(vtkOrientedImageData* image, vtkAbstractTransform* transform, bool geometryOnly=false, bool alwaysResample=false, bool linearInterpolation=false, double backgroundColor[4]=nullptr);
84 
88  static bool MergeImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* imageToAppend, vtkOrientedImageData* outputImage, int operation,
89  const int extent[6]=nullptr, double maskThreshold = 0, double fillValue = 1, bool *outputModified=nullptr);
90 
95  static bool ModifyImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* modifierImage, int operation,
96  const int extent[6] = nullptr, double maskThreshold = 0, double fillValue = 1);
97 
99  static bool CopyImage(vtkOrientedImageData* imageToCopy, vtkOrientedImageData* outputImage, const int extent[6]=nullptr);
100 
102  static void PrintImageInformation(vtkImageData* imageData, ostream& os, vtkIndent indent);
103 
106  static void FillImage(vtkImageData* image, double fillValue, const int extent[6]=nullptr);
107 
108 public:
110  static bool CalculateEffectiveExtent(vtkOrientedImageData* image, int effectiveExtent[6], double threshold = 0.0);
111 
114  static bool DoGeometriesMatch(vtkOrientedImageData* image1, vtkOrientedImageData* image2);
115 
117  static bool DoExtentsMatch(vtkOrientedImageData* image1, vtkOrientedImageData* image2);
118 
121  static bool DoGeometriesMatchIgnoreOrigin(vtkOrientedImageData* image1, vtkOrientedImageData* image2);
122 
125  static void TransformExtent(const int inputExtent[6], vtkAbstractTransform* inputToOutputTransform, int outputExtent[6]);
126 
129  static void TransformBounds(const double inputBounds[6], vtkAbstractTransform* inputToOutputTransform, double outputBounds[6]);
130 
132  static void TransformOrientedImageDataBounds(vtkOrientedImageData* image, vtkAbstractTransform* transform, double transformedBounds[6]);
133 
137  static bool IsEqual(vtkMatrix4x4* lhs, vtkMatrix4x4* rhs);
138 
140  static bool AreEqualWithTolerance(double a, double b) { return fabs(a - b) < 0.0001; };
141 
143  static bool GetTransformBetweenOrientedImages(vtkOrientedImageData* image1, vtkOrientedImageData* image2, vtkTransform* image1ToImage2Transform);
144 
146  static bool PadImageToContainImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* containedImage, vtkOrientedImageData* outputImage, const int extent[6]);
148  static bool PadImageToContainImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* containedImage, vtkOrientedImageData* outputImage);
149 
155  static bool IsTransformLinear(vtkAbstractTransform* transform, vtkTransform* linearTransform);
156 
158  static bool DoesTransformMatrixContainShear(vtkMatrix4x4* matrix);
159 
166  static bool ApplyImageMask(vtkOrientedImageData* input, vtkOrientedImageData* mask, double fillValue, bool notMask = false);
167 
175  static void GetLabelValuesInMask(std::vector<int>& labelValues, vtkOrientedImageData* binaryLabelmap, vtkOrientedImageData* mask,
176  const int extent[6]=nullptr, int maskThreshold = 0);
177 
184  static bool IsLabelInMask(vtkOrientedImageData* binaryLabelmap, vtkOrientedImageData* mask,
185  int extent[6]=nullptr, int maskThreshold=0);
186 
190  static void CastImageForValue(vtkOrientedImageData* image, double value);
191 
192 protected:
194  ~vtkOrientedImageDataResample() override;
195 
196 private:
198  void operator=(const vtkOrientedImageDataResample&) = delete;
199 };
200 
201 #endif
Utility functions for resampling oriented image data.
static bool AreEqualWithTolerance(double a, double b)
Compare two floating point numbers within tolerance.
Image data containing orientation information.