ITK  6.0.0
Insight Toolkit
itkChangeInformationImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 #ifndef itkChangeInformationImageFilter_h
19 #define itkChangeInformationImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkFixedArray.h"
23 
24 namespace itk
25 {
48 template <typename TInputImage>
49 class ITK_TEMPLATE_EXPORT ChangeInformationImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_MOVE(ChangeInformationImageFilter);
53 
59 
61  itkNewMacro(Self);
62 
63  using InputImageType = TInputImage;
64  using OutputImageType = TInputImage;
65 
69 
73 
75  using OutputImagePixelType = typename OutputImageType::PixelType;
76  using InputImagePixelType = typename InputImageType::PixelType;
77 
81  using OutputImageOffsetType = typename OutputImageType::OffsetType;
86  using InputImageOffsetType = typename InputImageType::OffsetType;
88 
90  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
91 
93  using SpacingType = typename InputImageType::SpacingType;
96 
98  itkOverrideGetNameOfClassMacro(ChangeInformationImageFilter);
99 
102  void
104  {
105  if (image != m_ReferenceImage)
106  {
107  m_ReferenceImage = image;
108  this->ProcessObject::SetNthInput(1, const_cast<InputImageType *>(image));
109  this->Modified();
110  }
111  }
114  itkGetModifiableObjectMacro(ReferenceImage, TInputImage);
115 
116  itkSetMacro(UseReferenceImage, bool);
117  itkBooleanMacro(UseReferenceImage);
118  itkGetConstMacro(UseReferenceImage, bool);
119 
123  itkSetMacro(OutputSpacing, SpacingType);
124  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
130  itkSetMacro(OutputOrigin, PointType);
131  itkGetConstReferenceMacro(OutputOrigin, PointType);
137  itkSetMacro(OutputDirection, DirectionType);
138  itkGetConstReferenceMacro(OutputDirection, DirectionType);
149  itkSetMacro(OutputOffset, OutputImageOffsetType);
150  itkGetConstReferenceMacro(OutputOffset, OutputImageOffsetType);
151  itkSetVectorMacro(OutputOffset, OutputImageOffsetValueType, ImageDimension);
155  void
157  {
158  this->ChangeSpacingOn();
159  this->ChangeOriginOn();
160  this->ChangeDirectionOn();
161  this->ChangeRegionOn();
162  }
167  void
169  {
170  this->ChangeSpacingOff();
171  this->ChangeOriginOff();
172  this->ChangeDirectionOff();
173  this->ChangeRegionOff();
174  }
183  itkSetMacro(ChangeSpacing, bool);
184  itkBooleanMacro(ChangeSpacing);
185  itkGetConstMacro(ChangeSpacing, bool);
186 
193  itkSetMacro(ChangeOrigin, bool);
194  itkBooleanMacro(ChangeOrigin);
195  itkGetConstMacro(ChangeOrigin, bool);
196 
203  itkSetMacro(ChangeDirection, bool);
204  itkBooleanMacro(ChangeDirection);
205  itkGetConstMacro(ChangeDirection, bool);
206 
209  itkSetMacro(ChangeRegion, bool);
210  itkBooleanMacro(ChangeRegion);
211  itkGetConstMacro(ChangeRegion, bool);
212 
216  itkSetMacro(CenterImage, bool);
217  itkBooleanMacro(CenterImage);
218  itkGetConstMacro(CenterImage, bool);
222  void
223  GenerateOutputInformation() override;
224 
226  void
227  GenerateInputRequestedRegion() override;
228 
230  void
231  GenerateData() override;
232 
233 protected:
234  ChangeInformationImageFilter() = default;
235  ~ChangeInformationImageFilter() override = default;
236 
237  void
238  PrintSelf(std::ostream & os, Indent indent) const override;
239 
245  void
246  VerifyInputInformation() const override
247  {}
248 
249 private:
250  InputImagePointer m_ReferenceImage{ nullptr };
251 
252  bool m_CenterImage{ false };
253  bool m_ChangeSpacing{ false };
254  bool m_ChangeOrigin{ false };
255  bool m_ChangeDirection{ false };
256  bool m_ChangeRegion{ false };
257  bool m_UseReferenceImage{ false };
258 
259  SpacingType m_OutputSpacing{ MakeFilled<SpacingType>(1.0) };
260  PointType m_OutputOrigin{};
261  DirectionType m_OutputDirection{ DirectionType::GetIdentity() };
262 
263  OutputImageOffsetType m_OutputOffset{};
265 };
266 } // end namespace itk
267 
268 #ifndef ITK_MANUAL_INSTANTIATION
269 # include "itkChangeInformationImageFilter.hxx"
270 #endif
271 
272 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ChangeInformationImageFilter::OutputImageOffsetType
typename OutputImageType::OffsetType OutputImageOffsetType
Definition: itkChangeInformationImageFilter.h:81
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::ChangeInformationImageFilter::OutputImageSizeType
typename OutputImageType::SizeType OutputImageSizeType
Definition: itkChangeInformationImageFilter.h:80
itk::ChangeInformationImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkChangeInformationImageFilter.h:75
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::ChangeInformationImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkChangeInformationImageFilter.h:68
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ChangeInformationImageFilter::DirectionType
typename InputImageType::DirectionType DirectionType
Definition: itkChangeInformationImageFilter.h:95
itk::ChangeInformationImageFilter::ChangeAll
void ChangeAll()
Definition: itkChangeInformationImageFilter.h:156
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ChangeInformationImageFilter
Change the origin, spacing and/or region of an Image.
Definition: itkChangeInformationImageFilter.h:49
itk::ChangeInformationImageFilter::InputImageOffsetType
typename InputImageType::OffsetType InputImageOffsetType
Definition: itkChangeInformationImageFilter.h:86
itk::ChangeInformationImageFilter::ChangeNone
void ChangeNone()
Definition: itkChangeInformationImageFilter.h:168
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::ChangeInformationImageFilter::InputImageIndexType
typename InputImageType::IndexType InputImageIndexType
Definition: itkChangeInformationImageFilter.h:84
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ChangeInformationImageFilter::OutputImageIndexType
typename OutputImageType::IndexType OutputImageIndexType
Definition: itkChangeInformationImageFilter.h:79
itkFixedArray.h
itk::ChangeInformationImageFilter::OutputImageType
TInputImage OutputImageType
Definition: itkChangeInformationImageFilter.h:64
itk::ChangeInformationImageFilter::OutputImageOffsetValueType
typename OutputImageType::OffsetValueType OutputImageOffsetValueType
Definition: itkChangeInformationImageFilter.h:83
itk::ChangeInformationImageFilter::SpacingType
typename InputImageType::SpacingType SpacingType
Definition: itkChangeInformationImageFilter.h:93
itk::ChangeInformationImageFilter::InputImageSizeType
typename InputImageType::SizeType InputImageSizeType
Definition: itkChangeInformationImageFilter.h:85
itkImageToImageFilter.h
itk::OffsetValueType
long OffsetValueType
Definition: itkIntTypes.h:97
itk::ChangeInformationImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkChangeInformationImageFilter.h:76
itk::ChangeInformationImageFilter::PointType
typename InputImageType::PointType PointType
Definition: itkChangeInformationImageFilter.h:94
itk::ChangeInformationImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkChangeInformationImageFilter.h:71
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject::SetNthInput
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
itk::ChangeInformationImageFilter::InputImageDirectionType
typename InputImageType::DirectionType InputImageDirectionType
Definition: itkChangeInformationImageFilter.h:87
itk::ChangeInformationImageFilter::InputImageType
TInputImage InputImageType
Definition: itkChangeInformationImageFilter.h:63
itk::ChangeInformationImageFilter::OutputImageDirectionType
typename OutputImageType::DirectionType OutputImageDirectionType
Definition: itkChangeInformationImageFilter.h:82
itk::ChangeInformationImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkChangeInformationImageFilter.h:67
itk::ChangeInformationImageFilter::VerifyInputInformation
void VerifyInputInformation() const override
Definition: itkChangeInformationImageFilter.h:246
itk::ChangeInformationImageFilter::SetReferenceImage
void SetReferenceImage(InputImageType *image)
Definition: itkChangeInformationImageFilter.h:103
itk::ChangeInformationImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkChangeInformationImageFilter.h:72