-
Notifications
You must be signed in to change notification settings - Fork 0
/
_3DMultimodalRegistration.h
134 lines (105 loc) · 4.58 KB
/
_3DMultimodalRegistration.h
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
#pragma once
class _3DMultimodalRegistration
{
private:
/* Static variables */
static const unsigned int Dimension = 3;
public:
typedef float PixelType;
typedef itk::Image< PixelType, Dimension > FixedImageType;
typedef itk::Image< PixelType, Dimension > MovingImageType;
typedef itk::ImageMaskSpatialObject<Dimension>::ImageType ImageMaskType;
//typedef itk::VersorRigid3DTransform< double > TransformType;
typedef itk::Euler3DTransform< double> TransformType;
FixedImageType::Pointer fixedImage;
MovingImageType::Pointer movingImage;
//typedef itk::RegularStepGradientDescentOptimizerv4<double> OptimizerType;
typedef itk::PowellOptimizerv4<double> OptimizerType;
//typedef itk::ConjugateGradientLineSearchOptimizerv4Template<double> OptimizerType;
//typedef itk::MeanSquaresImageToImageMetricv4< FixedImageType, MovingImageType > MetricType;
typedef itk::MattesMutualInformationImageToImageMetricv4< FixedImageType, MovingImageType > MetricType;
typedef itk::ImageRegistrationMethodv4<
FixedImageType,
MovingImageType,
TransformType > RegistrationType;
MetricType::Pointer metric = MetricType::New();
OptimizerType::Pointer optimizer = OptimizerType::New();
RegistrationType::Pointer registration = RegistrationType::New();
/*Private functions*/
private:
/* Timers */
itk::TimeProbesCollectorBase timer;
/* flags */
bool verbose = false;
bool ok = false;
bool customized_iso = false;
bool moving_mask = false;
bool fixed_mask = false;
bool debug = false;
bool resample = false;
bool resolution = false;
bool shrinking = false;
/* operators */
const double dtr = (atan(1.0) * 4.0) / 180.0;
double cx = 0;
double cy = -234;
double cz = 70;
/* Registration parameters */
const unsigned int numberOfLevels = 1;
double shrinkFactor = 1;
FixedImageType::SpacingType ResampleSpacing;
/* filenames */
std::string Outputfilename = "CBCT_registered.mha";
std::string OutputTransformfilename = "3DRigidRegistrationTransform.txt";
//std::string Iterationfilename = "3DRigidRegistrationIt.txt";
char* fixedImagefilename = NULL;
char* movingImagefilename = NULL;
char* movingMaskfilename = NULL;
char* fixedMaskfilename = NULL;
char* Orientation = "RAI";
/* Types */
TransformType::Pointer initialTransform = TransformType::New();
typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
typedef itk::ImageFileReader< ImageMaskType > MaskReaderType;
typedef itk::ImageMaskSpatialObject < Dimension > MaskType;
FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();
MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();
MaskReaderType::Pointer movingMaskReader = MaskReaderType::New();
MaskReaderType::Pointer fixedMaskReader = MaskReaderType::New();
MaskType::Pointer spatialObjectMovingMask = MaskType::New();
MaskType::Pointer spatialObjectFixedMask = MaskType::New();
typedef itk::CenteredTransformInitializer<
TransformType,
FixedImageType,
MovingImageType > TransformInitializerType;
TransformInitializerType::Pointer initializer =
TransformInitializerType::New();
//typedef TransformType::VersorType VersorType;
//typedef VersorType::VectorType VectorType;
//VersorType rotation;
//VectorType axis;
typedef OptimizerType::ScalesType OptimizerScalesType;
const double translationScale = 1.0;
const double rotationScale = 1.0 / dtr;
RegistrationType::ShrinkFactorsArrayType shrinkFactorsPerLevel;
RegistrationType::SmoothingSigmasArrayType smoothingSigmasPerLevel;
typedef unsigned char OutputPixelType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
//typedef itk::CastImageFilter< FixedImageType, OutputImageType > CastFilterType;
typedef itk::ImageFileWriter< FixedImageType > WriterType;
typedef itk::ResampleImageFilter<
MovingImageType,
FixedImageType > ResampleFilterType;
private:
//bool Initialize(FixedImageType::Pointer &fixedImage, MovingImageType::Pointer &movingImage);
bool Initialize();
//bool Resample(FixedImageType::Pointer InputImage, double shrinkfactor, FixedImageType::Pointer &OutputImage);
bool Resample(FixedImageType::Pointer InputImage, FixedImageType::SpacingType OutputSpacing, FixedImageType::Pointer &OutputImage);
public:
_3DMultimodalRegistration(int argc, char * argv[]);
//RegistrationClass();
virtual ~_3DMultimodalRegistration();
bool StartRegistration();
bool SetLevels();
};