RTK  2.0.1
Reconstruction Toolkit
rtkConstantImageSource.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef rtkConstantImageSource_h
20 #define rtkConstantImageSource_h
21 
22 #include "rtkConfiguration.h"
23 #include "rtkMacro.h"
24 
25 #include <itkImageSource.h>
26 #include <itkNumericTraits.h>
28 #include <itkVectorImage.h>
29 
30 namespace rtk
31 {
50 template <typename TOutputImage>
51 class ITK_EXPORT ConstantImageSource : public itk::ImageSource<TOutputImage>
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_ASSIGN(ConstantImageSource);
55 
61 
63  using OutputImageType = TOutputImage;
64 
66  using OutputImagePixelType = typename TOutputImage::PixelType;
67 
69  using OutputImageRegionType = typename TOutputImage::RegionType;
70 
73 
75  itkNewMacro(Self);
76 
78  using SizeType = typename TOutputImage::SizeType;
79  using IndexType = typename TOutputImage::IndexType;
80  using SpacingType = typename TOutputImage::SpacingType;
81  using PointType = typename TOutputImage::PointType;
82  using SizeValueType = typename SizeType::SizeValueType;
83  typedef SizeValueType SizeValueArrayType[TOutputImage::ImageDimension];
84  using SpacingValueType = typename TOutputImage::SpacingValueType;
85  typedef SpacingValueType SpacingValueArrayType[TOutputImage::ImageDimension];
86  using PointValueType = typename TOutputImage::PointValueType;
87  typedef PointValueType PointValueArrayType[TOutputImage::ImageDimension];
88  using DirectionType = typename TOutputImage::DirectionType;
89 
92  itkGetMacro( Size, SizeType );
93  virtual void SetSize( SizeValueArrayType sizeArray );
94  virtual const SizeValueType * GetSize() const;
96 
98  itkSetMacro( Spacing, SpacingType );
99  itkGetMacro( Spacing, SpacingType );
101 
103  itkSetMacro( Origin, PointType );
104  itkGetMacro( Origin, PointType );
106 
108  itkSetMacro( Direction, DirectionType );
109  itkGetMacro( Direction, DirectionType );
111 
114  itkGetMacro( Index, IndexType );
116 
119  itkGetConstMacro(Constant, OutputImagePixelType);
121 
123  void SetInformationFromImage(const itk::ImageBase<TOutputImage::ImageDimension>* image);
124 
125 protected:
127  ~ConstantImageSource() override;
128  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
129 
130 #if ITK_VERSION_MAJOR<5
131  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) override;
132 #else
133  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
134 #endif
135 
136  void GenerateOutputInformation() override;
137 
143 
145 };
146 
147 } // end namespace rtk
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "rtkConstantImageSource.hxx"
151 #endif
152 
153 #endif
typename TOutputImage::SizeType SizeType
typename SizeType::SizeValueType SizeValueType
Generate an n-dimensional image with constant pixel values.
typename TOutputImage::SpacingType SpacingType
typename TOutputImage::DirectionType DirectionType
typename TOutputImage::PointValueType PointValueType
typename TOutputImage::RegionType OutputImageRegionType
typename TOutputImage::IndexType IndexType
unsigned int ThreadIdType
OutputImagePixelType m_Constant
typename TOutputImage::PointType PointType
typename TOutputImage::PixelType OutputImagePixelType
typename TOutputImage::SpacingValueType SpacingValueType
#define itkSetMacro(name, type)