-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathitkMABMISDeformationFieldFilter.h
More file actions
143 lines (109 loc) · 6.37 KB
/
itkMABMISDeformationFieldFilter.h
File metadata and controls
143 lines (109 loc) · 6.37 KB
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
#ifndef __itkMABMISDeformationFieldFilter_h
#define __itkMABMISDeformationFieldFilter_h
#include <itkImage.h>
#include <itkImageToImageFilter.h>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkImageRegionIterator.h>
#include "itkImage.h"
#include "itkWarpImageFilter.h"
#include "itkAddImageFilter.h"
#include "itkDivideImageFilter.h"
#include "itkMultiplyImageFilter.h"
// interpolator
#include "itkLinearInterpolateImageFunction.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
#include "itkMABMISImageOperationFilter.h"
#include "itkWarpVectorImageFilter.h"
#define ImageDimension 3
namespace itk
{
namespace Statistics
{
template <class TInputImage, class TOutputImage>
class MABMISDeformationFieldFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef MABMISDeformationFieldFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
typedef TInputImage ImageType;
typedef typename ImageType::Pointer ImagePointerType;
typedef unsigned char CharPixelType; // for image IO usage
typedef float FloatPixelType; // for
typedef int IntPixelType;
typedef short ShortPixelType;
typedef float InternalPixelType; // for internal processing usage
typedef itk::Vector<InternalPixelType, ImageDimension> VectorPixelType;
// basic image type
typedef itk::Image<CharPixelType, ImageDimension> CharImageType;
typedef itk::Image<IntPixelType, ImageDimension> IntImageType;
typedef itk::Image<ShortPixelType, ImageDimension> ShortImageType;
typedef itk::Image<FloatPixelType, ImageDimension> FloatImageType;
typedef itk::Image<InternalPixelType, ImageDimension> InternalImageType;
typedef itk::Image<VectorPixelType, ImageDimension> DeformationFieldType;
typedef itk::ImageFileReader<DeformationFieldType> DeformationFieldReaderType;
typedef itk::ImageFileWriter<DeformationFieldType> DeformationFieldWriterType;
typedef itk::WarpVectorImageFilter<DeformationFieldType, DeformationFieldType,
DeformationFieldType> WarpVectorFilterType;
typedef itk::MultiplyImageFilter<DeformationFieldType, float,
DeformationFieldType> MultiplyDeformationFieldFilterType;
typedef itk::DivideImageFilter<DeformationFieldType, float,
DeformationFieldType> DivideDeformationFieldFilterType;
typedef itk::AddImageFilter<DeformationFieldType, DeformationFieldType,
DeformationFieldType> AddImageFilterType;
// basic iterator type
typedef itk::ImageRegionIterator<DeformationFieldType> DeformationFieldIteratorType;
typedef itk::ImageRegionIterator<InternalImageType> InternalImageIteratorType;
typedef itk::ImageRegionIterator<CharImageType> CharImageIteratorType;
// interpolator type
typedef itk::LinearInterpolateImageFunction<InternalImageType, double> InternalLinearInterpolatorType;
typedef itk::NearestNeighborInterpolateImageFunction<InternalImageType, double> InternalNNInterpolatorType;
typedef itk::WarpImageFilter<InternalImageType, InternalImageType, DeformationFieldType> InternalWarpFilterType;
typedef itk::Statistics::MABMISImageOperationFilter<ImageType, ImageType> ImageOperationType;
typename ImageOperationType::Pointer imgoperator;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(MABMISDeformationFieldFilter, ImageToImageFilter);
DeformationFieldType::SpacingType df_spacing;
DeformationFieldType::DirectionType df_direction;
DeformationFieldType::PointType df_origin;
int ReadDeformationField(std::string filename, DeformationFieldType::Pointer & deformationfield);
void WriteDeformationField(std::string filename, DeformationFieldType::Pointer deformationfield);
void ComposeDeformationFieldsAndSave(std::string inputDeformationFieldFileName, std::string deformationFieldFileName,
std::string composedDeformationFieldFileName);
void ComposeDeformationFields(DeformationFieldType::Pointer input, DeformationFieldType::Pointer deformationField,
DeformationFieldType::Pointer & composedDeformationField);
void InverseDeformationField3D(DeformationFieldType::Pointer deformationField,
DeformationFieldType::Pointer & deformationFieldInverse);
void ApplyDeformationField(InternalImageType::Pointer movingImage, DeformationFieldType::Pointer deformationField,
InternalImageType::Pointer & deformedImage, bool isLinearInterpolator);
void ApplyDeformationFieldAndWriteWithFileNames(std::string movingImageName, std::string deformationFieldFileName,
std::string deformedImageName, bool isLinearInterpolator);
void ApplyDeformationFieldAndWriteWithTypeWithFileNames(std::string movingImageFileName,
std::string deformationFieldFileName,
std::string deformedImageFileName, bool isLinear);
void DownResampleDeformationField(std::string deformationFieldFileName, std::string resampledDeformationFieldFileName,
int sampleRate);
void UpResampleDeformationField(std::string deformationFieldFileName, std::string resampledDeformationFieldFileName,
int sampleRate);
itkSetMacro(Imx, int);
itkSetMacro(Imy, int);
itkSetMacro(Imz, int);
private:
MABMISDeformationFieldFilter(const Self &); // purposely not implemented
void operator=(const Self &); // purposely not implemented
int m_Imx;
int m_Imy;
int m_Imz;
protected:
MABMISDeformationFieldFilter();
~MABMISDeformationFieldFilter();
void PrintSelf(std::ostream& os, Indent indent) const;
};
} // namespace itk
} // namespace Statistics
#include "itkMABMISDeformationFieldFilter.hxx"
#endif