Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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 "vtkSegmentationCoreExport.h"
26
27// VTK includes
28#include "vtkObject.h"
29
30// std includes
31#include <vector>
32#include <cmath> // for fabs
33
34class vtkImageData;
35class vtkIntArray;
36class vtkMatrix4x4;
38class vtkTransform;
39class vtkAbstractTransform;
40
42class vtkSegmentationCore_EXPORT vtkOrientedImageDataResample : public vtkObject
43{
44public:
46 vtkTypeMacro(vtkOrientedImageDataResample, vtkObject);
47
48 enum
49 {
53 };
54
63 vtkMatrix4x4* referenceGeometryMatrix,
64 vtkOrientedImageData* outputImage,
65 bool linearInterpolation = false);
66
77 vtkOrientedImageData* referenceImage,
78 vtkOrientedImageData* outputImage,
79 bool linearInterpolation = false,
80 bool padImage = false,
81 vtkAbstractTransform* inputImageTransform = nullptr,
82 double backgroundValue = 0);
83
93 vtkAbstractTransform* transform,
94 bool geometryOnly = false,
95 bool alwaysResample = false,
96 bool linearInterpolation = false,
97 double backgroundColor[4] = nullptr);
98
102 static bool MergeImage(vtkOrientedImageData* inputImage,
103 vtkOrientedImageData* imageToAppend,
104 vtkOrientedImageData* outputImage,
105 int operation,
106 const int extent[6] = nullptr,
107 double maskThreshold = 0,
108 double fillValue = 1,
109 bool* outputModified = nullptr);
110
115 static bool ModifyImage(vtkOrientedImageData* inputImage,
116 vtkOrientedImageData* modifierImage,
117 int operation,
118 const int extent[6] = nullptr,
119 double maskThreshold = 0,
120 double fillValue = 1);
121
123 static bool CopyImage(vtkOrientedImageData* imageToCopy, vtkOrientedImageData* outputImage, const int extent[6] = nullptr);
124
126 static void PrintImageInformation(vtkImageData* imageData, ostream& os, vtkIndent indent);
127
130 static void FillImage(vtkImageData* image, double fillValue, const int extent[6] = nullptr);
131
132public:
134 static bool CalculateEffectiveExtent(vtkOrientedImageData* image, int effectiveExtent[6], double threshold = 0.0);
135
145 static bool CalculateEffectiveExtentPerLabel(vtkImageData* image, vtkIntArray* labelValues, vtkIntArray* labelExtents);
146
148 static void InvalidateExtent(int extent[6]);
149
153
156
160
163 static void TransformExtent(const int inputExtent[6], vtkAbstractTransform* inputToOutputTransform, int outputExtent[6]);
164
167 static void TransformBounds(const double inputBounds[6], vtkAbstractTransform* inputToOutputTransform, double outputBounds[6]);
168
170 static void TransformOrientedImageDataBounds(vtkOrientedImageData* image, vtkAbstractTransform* transform, double transformedBounds[6]);
171
175 static bool IsEqual(vtkMatrix4x4* lhs, vtkMatrix4x4* rhs);
176
178 static bool AreEqualWithTolerance(double a, double b) { return fabs(a - b) < 0.0001; };
179
181 static bool GetTransformBetweenOrientedImages(vtkOrientedImageData* image1, vtkOrientedImageData* image2, vtkTransform* image1ToImage2Transform);
182
184 static bool PadImageToContainImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* containedImage, vtkOrientedImageData* outputImage, const int extent[6]);
186 static bool PadImageToContainImage(vtkOrientedImageData* inputImage, vtkOrientedImageData* containedImage, vtkOrientedImageData* outputImage);
187
193 static bool IsTransformLinear(vtkAbstractTransform* transform, vtkTransform* linearTransform);
194
196 static bool DoesTransformMatrixContainShear(vtkMatrix4x4* matrix);
197
204 static bool ApplyImageMask(vtkOrientedImageData* input, vtkOrientedImageData* mask, double fillValue, bool notMask = false);
205
213 static void GetLabelValuesInMask(std::vector<int>& labelValues,
214 vtkOrientedImageData* binaryLabelmap,
216 const int extent[6] = nullptr,
217 int maskThreshold = 0);
218
225 static bool IsLabelInMask(vtkOrientedImageData* binaryLabelmap, vtkOrientedImageData* mask, int extent[6] = nullptr, int maskThreshold = 0);
226
235
240 static int IsImageScalarTypeValid(vtkImageData* image);
241
246 static int GetSmallestIntegerTypeForSegmentationScalarRange(double scalarRange[2]);
247
251 static bool CastSegmentationToSmallestIntegerType(vtkImageData* image);
252
257 static bool CastSegmentationToSmallestIntegerType(vtkImageData* image, double scalarRange[2]);
258
262 static void CastImageForValue(vtkImageData* image, double value);
263
264protected:
267
268private:
270 void operator=(const vtkOrientedImageDataResample&) = delete;
271};
272
273#endif
static bool CopyImage(vtkOrientedImageData *imageToCopy, vtkOrientedImageData *outputImage, const int extent[6]=nullptr)
Copy image with clipping to the specified extent.
static bool ResampleOrientedImageToReferenceOrientedImage(vtkOrientedImageData *inputImage, vtkOrientedImageData *referenceImage, vtkOrientedImageData *outputImage, bool linearInterpolation=false, bool padImage=false, vtkAbstractTransform *inputImageTransform=nullptr, double backgroundValue=0)
static void CastImageForValue(vtkImageData *image, double value)
static bool MergeImage(vtkOrientedImageData *inputImage, vtkOrientedImageData *imageToAppend, vtkOrientedImageData *outputImage, int operation, const int extent[6]=nullptr, double maskThreshold=0, double fillValue=1, bool *outputModified=nullptr)
static void TransformOrientedImage(vtkOrientedImageData *image, vtkAbstractTransform *transform, bool geometryOnly=false, bool alwaysResample=false, bool linearInterpolation=false, double backgroundColor[4]=nullptr)
static bool CastSegmentationToSmallestIntegerType(vtkImageData *image, double scalarRange[2])
static bool CastSegmentationToSmallestIntegerType(vtkImageData *image)
static bool IsEqual(vtkMatrix4x4 *lhs, vtkMatrix4x4 *rhs)
static bool DoGeometriesMatchIgnoreOrigin(vtkOrientedImageData *image1, vtkOrientedImageData *image2)
static void PrintImageInformation(vtkImageData *imageData, ostream &os, vtkIndent indent)
Prints image information. Does not print lots of irrelevant information that default PrintSelf would ...
static bool PadImageToContainImage(vtkOrientedImageData *inputImage, vtkOrientedImageData *containedImage, vtkOrientedImageData *outputImage, const int extent[6])
Pad an image to entirely contain another image using custom extent to contain.
static bool ResampleOrientedImageToReferenceGeometry(vtkOrientedImageData *inputImage, vtkMatrix4x4 *referenceGeometryMatrix, vtkOrientedImageData *outputImage, bool linearInterpolation=false)
~vtkOrientedImageDataResample() override
static bool ApplyImageMask(vtkOrientedImageData *input, vtkOrientedImageData *mask, double fillValue, bool notMask=false)
static bool DoesTransformMatrixContainShear(vtkMatrix4x4 *matrix)
Determine if a transform matrix contains shear.
static void GetLabelValuesInMask(std::vector< int > &labelValues, vtkOrientedImageData *binaryLabelmap, vtkOrientedImageData *mask, const int extent[6]=nullptr, int maskThreshold=0)
static int GetSmallestIntegerTypeForSegmentationScalarRange(double scalarRange[2])
static bool ModifyImage(vtkOrientedImageData *inputImage, vtkOrientedImageData *modifierImage, int operation, const int extent[6]=nullptr, double maskThreshold=0, double fillValue=1)
static void FillImage(vtkImageData *image, double fillValue, const int extent[6]=nullptr)
static bool DoExtentsMatch(vtkOrientedImageData *image1, vtkOrientedImageData *image2)
Determine if extents of two oriented image data objects match.
static void TransformExtent(const int inputExtent[6], vtkAbstractTransform *inputToOutputTransform, int outputExtent[6])
static int IsImageScalarTypeValid(vtkImageData *image)
static bool AreEqualWithTolerance(double a, double b)
Compare two floating point numbers within tolerance.
static bool PadImageToContainImage(vtkOrientedImageData *inputImage, vtkOrientedImageData *containedImage, vtkOrientedImageData *outputImage)
Pad an image to entirely contain another image.
static vtkOrientedImageDataResample * New()
static bool CalculateEffectiveExtentPerLabel(vtkImageData *image, vtkIntArray *labelValues, vtkIntArray *labelExtents)
static bool IsTransformLinear(vtkAbstractTransform *transform, vtkTransform *linearTransform)
static bool GetTransformBetweenOrientedImages(vtkOrientedImageData *image1, vtkOrientedImageData *image2, vtkTransform *image1ToImage2Transform)
Calculate transform between two oriented image data.
static bool DoGeometriesMatch(vtkOrientedImageData *image1, vtkOrientedImageData *image2)
static void InvalidateExtent(int extent[6])
Set extent to [0,-1,0,-1,0,-1].
static void TransformBounds(const double inputBounds[6], vtkAbstractTransform *inputToOutputTransform, double outputBounds[6])
static void TransformOrientedImageDataBounds(vtkOrientedImageData *image, vtkAbstractTransform *transform, double transformedBounds[6])
Transform bounds of oriented image data using a linear or non-linear transform.
static bool IsLabelInMask(vtkOrientedImageData *binaryLabelmap, vtkOrientedImageData *mask, int extent[6]=nullptr, int maskThreshold=0)
static bool CalculateEffectiveExtent(vtkOrientedImageData *image, int effectiveExtent[6], double threshold=0.0)
Calculate effective extent of an image: the IJK extent where non-zero voxels are located.
Image data containing orientation information.