ITK  6.0.0
Insight Toolkit
itkOrientImageFilter.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 itkOrientImageFilter_h
19 #define itkOrientImageFilter_h
20 
22 #include "itkFlipImageFilter.h"
24 #include <map>
25 #include <string>
26 
27 namespace itk
28 {
72 template <typename TInputImage, typename TOutputImage>
73 class ITK_TEMPLATE_EXPORT OrientImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
74 {
75 public:
76  ITK_DISALLOW_COPY_AND_MOVE(OrientImageFilter);
77 
79  using Self = OrientImageFilter;
80  using Superclass = ImageToImageFilter<TInputImage, TOutputImage>;
81  using Pointer = SmartPointer<Self>;
82  using ConstPointer = SmartPointer<const Self>;
83 
85  using InputImageType = TInputImage;
86  using InputImagePointer = typename InputImageType::Pointer;
87  using InputImageConstPointer = typename InputImageType::ConstPointer;
88  using InputImageRegionType = typename InputImageType::RegionType;
89  using InputImagePixelType = typename InputImageType::PixelType;
90  using OutputImageType = TOutputImage;
91  using OutputImagePointer = typename OutputImageType::Pointer;
92  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
93  using OutputImageRegionType = typename OutputImageType::RegionType;
94  using OutputImagePixelType = typename OutputImageType::PixelType;
95  using CoordinateOrientationCode = AnatomicalOrientation;
96 
98  using PermuterType = PermuteAxesImageFilter<TInputImage>;
99  using PermuteOrderArrayType = typename PermuterType::PermuteOrderArrayType;
100 
102  using FlipperType = FlipImageFilter<TInputImage>;
103  using FlipAxesArrayType = typename FlipperType::FlipAxesArrayType;
104 
106  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
107  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
108 
110  itkNewMacro(Self);
111 
113  itkOverrideGetNameOfClassMacro(OrientImageFilter);
114 
116  itkGetEnumMacro(GivenCoordinateOrientation, CoordinateOrientationCode);
117  void
118  SetGivenCoordinateOrientation(CoordinateOrientationCode newCode);
121  inline void
122  SetGivenCoordinateDirection(const typename TInputImage::DirectionType & GivenDirection)
123  {
124  SetGivenCoordinateOrientation(AnatomicalOrientation(GivenDirection));
125  }
126 
127  itkGetEnumMacro(DesiredCoordinateOrientation, CoordinateOrientationCode);
128  void
129  SetDesiredCoordinateOrientation(CoordinateOrientationCode newCode);
130 
131  inline void
132  SetDesiredCoordinateDirection(const typename TOutputImage::DirectionType & DesiredDirection)
133  {
134  SetDesiredCoordinateOrientation(AnatomicalOrientation(DesiredDirection));
135  }
136 
145  itkBooleanMacro(UseImageDirection);
146  itkGetConstMacro(UseImageDirection, bool);
147  itkSetMacro(UseImageDirection, bool);
151  itkGetConstReferenceMacro(PermuteOrder, PermuteOrderArrayType);
152 
154  itkGetConstReferenceMacro(FlipAxes, FlipAxesArrayType);
155 
166  void
167  SetDesiredCoordinateOrientationToAxial()
168  {
169  this->SetDesiredCoordinateOrientation({ AnatomicalOrientation::CoordinateEnum::RightToLeft,
172  }
175  void
176  SetDesiredCoordinateOrientationToCoronal()
177  {
178  this->SetDesiredCoordinateOrientation({ AnatomicalOrientation::CoordinateEnum::RightToLeft,
181  }
182 
183  void
184  SetDesiredCoordinateOrientationToSagittal()
185  {
186  this->SetDesiredCoordinateOrientation({ AnatomicalOrientation::CoordinateEnum::AnteriorToPosterior,
189  }
190 
198  void
199  GenerateOutputInformation() override;
200 
201 #ifdef ITK_USE_CONCEPT_CHECKING
202  // Begin concept checking
203  itkConceptMacro(InputConvertibleToOutput, (Concept::Convertible<InputImagePixelType, OutputImagePixelType>));
204  itkConceptMacro(SameDimension, (Concept::SameDimension<Self::InputImageDimension, Self::OutputImageDimension>));
205  itkConceptMacro(DimensionShouldBe3, (Concept::SameDimension<Self::InputImageDimension, 3>));
206  // End concept checking
207 #endif
208 
209 protected:
210  OrientImageFilter();
211  ~OrientImageFilter() override = default;
212  void
213  PrintSelf(std::ostream & os, Indent indent) const override;
214 
218  void
219  GenerateInputRequestedRegion() override;
220 
222  void
223  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
224 
225  void
226  VerifyPreconditions() const override;
227 
228  /*** Member functions used by GenerateData: */
229  void
230  DeterminePermutationsAndFlips(const CoordinateOrientationCode fixed_orient,
231  const CoordinateOrientationCode moving_orient);
232 
234  bool
235  NeedToPermute();
236 
238  bool
239  NeedToFlip();
240 
243  void
244  GenerateData() override;
245 
246 private:
247  CoordinateOrientationCode m_GivenCoordinateOrientation{ AnatomicalOrientation::CoordinateEnum::RightToLeft,
250  CoordinateOrientationCode m_DesiredCoordinateOrientation{
254  };
255  bool m_UseImageDirection{ false };
256 
257  PermuteOrderArrayType m_PermuteOrder{};
258  FlipAxesArrayType m_FlipAxes{ false };
259 
260 }; // end of class
261 } // end namespace itk
262 
263 #ifndef ITK_MANUAL_INSTANTIATION
264 # include "itkOrientImageFilter.hxx"
265 #endif
266 
267 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::AnatomicalOrientation::CoordinateEnum::SuperiorToInferior
to foot
itk::AnatomicalOrientation::CoordinateEnum::LeftToRight
itkFlipImageFilter.h
itk::AnatomicalOrientation::CoordinateEnum::PosteriorToAnterior
to front - 0b0100
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkAnatomicalOrientation.h
itk::AnatomicalOrientation::CoordinateEnum::AnteriorToPosterior
to back
itk::DataObject
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::AnatomicalOrientation::CoordinateEnum::RightToLeft
0b0010
itkPermuteAxesImageFilter.h
itk::AnatomicalOrientation::CoordinateEnum::InferiorToSuperior
to head - 0b1000
AddImageFilter
Definition: itkAddImageFilter.h:81
Superclass
BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage > Superclass
Definition: itkAddImageFilter.h:90