ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkOrientImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software 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 #ifndef __itkOrientImageFilter_h
19 #define __itkOrientImageFilter_h
20 
22 #include "itkFlipImageFilter.h"
24 #include <map>
25 #include <string>
26 
27 namespace itk
28 {
139 template< class TInputImage, class TOutputImage >
140 class ITK_EXPORT OrientImageFilter:
141  public ImageToImageFilter< TInputImage, TOutputImage >
142 {
143 public:
149 
151  typedef TInputImage InputImageType;
152  typedef typename InputImageType::Pointer InputImagePointer;
153  typedef typename InputImageType::ConstPointer InputImageConstPointer;
154  typedef typename InputImageType::RegionType InputImageRegionType;
155  typedef typename InputImageType::PixelType InputImagePixelType;
156  typedef TOutputImage OutputImageType;
157  typedef typename OutputImageType::Pointer OutputImagePointer;
158  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
159  typedef typename OutputImageType::RegionType OutputImageRegionType;
160  typedef typename OutputImageType::PixelType OutputImagePixelType;
163 
167 
171 
173  itkStaticConstMacro(InputImageDimension, unsigned int,
174  TInputImage::ImageDimension);
175  itkStaticConstMacro(OutputImageDimension, unsigned int,
176  TOutputImage::ImageDimension);
178 
180  itkNewMacro(Self);
181 
183  itkTypeMacro(OrientImageFilter, ImageToImageFilter);
184 
186  itkGetEnumMacro(GivenCoordinateOrientation, CoordinateOrientationCode);
187  void SetGivenCoordinateOrientation(CoordinateOrientationCode newCode);
189 
190  inline void SetGivenCoordinateDirection(const typename TInputImage::DirectionType & GivenDirection)
191  {
192  SetGivenCoordinateOrientation(
193  itk::SpatialOrientationAdapter().FromDirectionCosines(GivenDirection) );
194  }
195 
196  itkGetEnumMacro(DesiredCoordinateOrientation, CoordinateOrientationCode);
197  void SetDesiredCoordinateOrientation(CoordinateOrientationCode newCode);
198 
199  inline void SetDesiredCoordinateDirection(const typename TOutputImage::DirectionType & DesiredDirection)
200  {
201  SetDesiredCoordinateOrientation(
202  itk::SpatialOrientationAdapter().FromDirectionCosines(DesiredDirection) );
203  }
204 
212  itkBooleanMacro(UseImageDirection);
213  itkGetConstMacro(UseImageDirection, bool);
214  itkSetMacro(UseImageDirection, bool);
216 
218  itkGetConstReferenceMacro(PermuteOrder, PermuteOrderArrayType);
219 
221  itkGetConstReferenceMacro(FlipAxes, FlipAxesArrayType);
222 
236  void SetDesiredCoordinateOrientationToAxial()
237  {
238  this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
239  }
240 
241  void SetDesiredCoordinateOrientationToCoronal()
242  {
243  this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA);
244  }
245 
246  void SetDesiredCoordinateOrientationToSagittal()
247  {
248  this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASL);
249  }
250 
258  virtual void GenerateOutputInformation();
259 
260 #ifdef ITK_USE_CONCEPT_CHECKING
261 
262  itkConceptMacro( InputConvertibleToOutput,
264  itkConceptMacro( SameDimension,
265  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension),
266  itkGetStaticConstMacro(OutputImageDimension) > ) );
267  itkConceptMacro( DimensionShouldBe3,
268  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension), 3 > ) );
269 
271 #endif
272 
273 protected:
276  void PrintSelf(std::ostream & os, Indent indent) const;
277 
281  void GenerateInputRequestedRegion();
282 
284  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
285 
286 /*** Member functions used by GenerateData: */
287  void DeterminePermutationsAndFlips(const SpatialOrientation::ValidCoordinateOrientationFlags fixed_orient,
289 
290  bool NeedToPermute();
291 
292  bool NeedToFlip();
293 
296  void GenerateData();
297 
298 private:
299  OrientImageFilter(const Self &); //purposely not implemented
300  void operator=(const Self &); //purposely not implemented
301 
302  std::string GetMajorAxisFromPatientRelativeDirectionCosine(double x, double y, double z);
303 
307 
310 
311  std::map< std::string, CoordinateOrientationCode > m_StringToCode;
312  std::map< CoordinateOrientationCode, std::string > m_CodeToString;
313 }; // end of class
314 } // end namespace itk
315 
316 #ifndef ITK_MANUAL_INSTANTIATION
317 #include "itkOrientImageFilter.hxx"
318 #endif
319 
320 #endif
321