-
Notifications
You must be signed in to change notification settings - Fork 145
/
rtkConstantImageSource.h
153 lines (127 loc) · 5.02 KB
/
rtkConstantImageSource.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*=========================================================================
*
* Copyright RTK Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef rtkConstantImageSource_h
#define rtkConstantImageSource_h
#include "rtkConfiguration.h"
#include "rtkMacro.h"
#include <itkImageSource.h>
#include <itkNumericTraits.h>
#include <itkVariableLengthVector.h>
#include <itkVectorImage.h>
namespace rtk
{
/** \class ConstantImageSource
* \brief Generate an n-dimensional image with constant pixel values.
*
* ConstantImageSource generates an image with constant value. The filter is
* useful to allow streaming of large images with a constant source, e.g., a
* tomography reconstructed with a filtered backprojection algorithm.
*
* \test rtkRaycastInterpolatorForwardProjectionTest.cxx,
* rtkprojectgeometricphantomtest.cxx, rtkfdktest.cxx, rtksarttest.cxx,
* rtkrampfiltertest.cxx, rtkamsterdamshroudtest.cxx,
* rtkdrawgeometricphantomtest.cxx, rtkmotioncompensatedfdktest.cxx,
* rtkfovtest.cxx, rtkforwardprojectiontest.cxx, rtkdisplaceddetectortest.cxx,
* rtkshortscantest.cxx
*
* \author Simon Rit
*
* \ingroup RTK ImageSource
*/
template <typename TOutputImage>
class ITK_TEMPLATE_EXPORT ConstantImageSource : public itk::ImageSource<TOutputImage>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(ConstantImageSource);
/** Standard class type alias. */
using Self = ConstantImageSource;
using Superclass = itk::ImageSource<TOutputImage>;
using Pointer = itk::SmartPointer<Self>;
using ConstPointer = itk::SmartPointer<const Self>;
/** Typedef for the output image type. */
using OutputImageType = TOutputImage;
/** Typedefs for the output image PixelType. */
using OutputImagePixelType = typename TOutputImage::PixelType;
/** Typedef to describe the output image region type. */
using OutputImageRegionType = typename TOutputImage::RegionType;
/** Run-time type information (and related methods). */
#ifdef itkOverrideGetNameOfClassMacro
itkOverrideGetNameOfClassMacro(ConstantImageSource);
#else
itkTypeMacro(ConstantImageSource, itk::ImageSource);
#endif
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Basic types from the OutputImageType */
using SizeType = typename TOutputImage::SizeType;
using IndexType = typename TOutputImage::IndexType;
using SpacingType = typename TOutputImage::SpacingType;
using PointType = typename TOutputImage::PointType;
using SizeValueType = typename SizeType::SizeValueType;
typedef SizeValueType SizeValueArrayType[TOutputImage::ImageDimension];
using SpacingValueType = typename TOutputImage::SpacingValueType;
typedef SpacingValueType SpacingValueArrayType[TOutputImage::ImageDimension];
using PointValueType = typename TOutputImage::PointValueType;
typedef PointValueType PointValueArrayType[TOutputImage::ImageDimension];
using DirectionType = typename TOutputImage::DirectionType;
/** Set/Get size of the output image */
itkSetMacro(Size, SizeType);
itkGetMacro(Size, SizeType);
virtual void
SetSize(SizeValueArrayType sizeArray);
virtual const SizeValueType *
GetSize() const;
/** Set/Get spacing of the output image */
itkSetMacro(Spacing, SpacingType);
itkGetMacro(Spacing, SpacingType);
/** Set/Get origin of the output image */
itkSetMacro(Origin, PointType);
itkGetMacro(Origin, PointType);
/** Set/Get direction of the output image */
itkSetMacro(Direction, DirectionType);
itkGetMacro(Direction, DirectionType);
/** Set/Get index of the output image's largest possible region */
itkSetMacro(Index, IndexType);
itkGetMacro(Index, IndexType);
/** Set/Get the pixel value of output */
itkSetMacro(Constant, OutputImagePixelType);
itkGetConstMacro(Constant, OutputImagePixelType);
/** Set output image information from an existing image */
void
SetInformationFromImage(const itk::ImageBase<TOutputImage::ImageDimension> * image);
protected:
ConstantImageSource();
~ConstantImageSource() override;
void
PrintSelf(std::ostream & os, itk::Indent indent) const override;
void
DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
void
GenerateOutputInformation() override;
SizeType m_Size;
SpacingType m_Spacing;
PointType m_Origin;
DirectionType m_Direction;
IndexType m_Index;
OutputImagePixelType m_Constant;
};
} // end namespace rtk
#ifndef ITK_MANUAL_INSTANTIATION
# include "rtkConstantImageSource.hxx"
#endif
#endif