Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkOrientImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkOrientImageFilter.h,v $
00005 Language:  C++
00006 Date:      $Date: 2007-08-20 18:06:22 $
00007 Version:   $Revision: 1.10 $
00008 
00009 Copyright (c) Insight Software Consortium. All rights reserved.
00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012 This software is distributed WITHOUT ANY WARRANTY; without even
00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014 PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkOrientImageFilter_h
00018 #define __itkOrientImageFilter_h
00019 
00020 #include "itkImageToImageFilter.h"
00021 #include "itkIOCommon.h"
00022 #include "itkPermuteAxesImageFilter.h"
00023 #include "itkFlipImageFilter.h"
00024 #include "itkSpatialOrientation.h"
00025 #include "itkSpatialOrientationAdapter.h"
00026 #include <map>
00027 #include <string>
00028 
00029 namespace itk {
00030 
00143 template<class TInputImage, class TOutputImage>
00144 class ITK_EXPORT OrientImageFilter :
00145     public ImageToImageFilter<TInputImage, TOutputImage>
00146 {
00147 public:
00149   typedef OrientImageFilter Self;
00150   typedef ImageToImageFilter<TInputImage, TOutputImage>
00151   Superclass;
00152   typedef SmartPointer<Self>        Pointer;
00153   typedef SmartPointer<const Self>  ConstPointer;
00154 
00156   typedef TInputImage InputImageType;
00157   typedef TOutputImage OutputImageType;
00158   typedef typename InputImageType::Pointer         InputImagePointer;
00159   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00160   typedef typename InputImageType::RegionType      InputImageRegionType;
00161   typedef typename InputImageType::PixelType       InputImagePixelType;
00162   typedef typename OutputImageType::Pointer        OutputImagePointer;
00163   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00164   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00165   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00166   typedef SpatialOrientation::ValidCoordinateOrientationFlags
00167   CoordinateOrientationCode;
00168 
00170   typedef PermuteAxesImageFilter< TInputImage > PermuterType;
00171   typedef typename PermuterType::PermuteOrderArrayType PermuteOrderArrayType;
00172 
00174   typedef FlipImageFilter< TInputImage > FlipperType;
00175   typedef typename FlipperType::FlipAxesArrayType  FlipAxesArrayType;
00176 
00177   
00179   itkStaticConstMacro(InputImageDimension, unsigned int,
00180                       TInputImage::ImageDimension);
00181   itkStaticConstMacro(OutputImageDimension, unsigned int,
00182                       TOutputImage::ImageDimension);
00184 
00186   itkNewMacro(Self);
00187 
00189   itkTypeMacro(OrientImageFilter, ImageToImageFilter);
00190 
00192   itkGetEnumMacro(GivenCoordinateOrientation, CoordinateOrientationCode);
00193   void SetGivenCoordinateOrientation(CoordinateOrientationCode newCode);
00194   inline void SetGivenCoordinateDirection(const typename TInputImage::DirectionType &GivenDirection)
00195     {
00196     SetGivenCoordinateOrientation(
00197     itk::SpatialOrientationAdapter().FromDirectionCosines(GivenDirection));
00198     }
00199   itkGetEnumMacro(DesiredCoordinateOrientation, CoordinateOrientationCode);
00200   void SetDesiredCoordinateOrientation(CoordinateOrientationCode newCode);
00201   inline void SetDesiredCoordinateDirection(const typename TOutputImage::DirectionType &DesiredDirection)
00202     {
00203     SetDesiredCoordinateOrientation(
00204     itk::SpatialOrientationAdapter().FromDirectionCosines(DesiredDirection));
00205     }
00207 
00215   itkBooleanMacro(UseImageDirection);
00216   itkGetMacro(UseImageDirection, bool);
00217   itkSetMacro(UseImageDirection, bool);
00219 
00221   itkGetConstReferenceMacro( PermuteOrder, PermuteOrderArrayType );
00222 
00224   itkGetConstReferenceMacro( FlipAxes, FlipAxesArrayType );
00225 
00239   void SetDesiredCoordinateOrientationToAxial ()
00240     {
00241    this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
00242     }
00243   void SetDesiredCoordinateOrientationToCoronal ()
00244     {
00245     this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA);
00246     }
00247   void SetDesiredCoordinateOrientationToSagittal ()
00248     {
00249     this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASL);
00250     }
00252 
00260   virtual void GenerateOutputInformation();
00261 
00262 #ifdef ITK_USE_CONCEPT_CHECKING
00263 
00264   itkConceptMacro(InputConvertibleToOutput,
00265     (Concept::Convertible<InputImagePixelType, OutputImagePixelType>));
00266   itkConceptMacro(SameDimension,
00267     (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),itkGetStaticConstMacro(OutputImageDimension)>));
00268   itkConceptMacro(DimensionShouldBe3,
00269     (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),3>));
00270 
00272 #endif
00273 
00274 protected:
00275   OrientImageFilter();
00276   ~OrientImageFilter() {};
00277   void PrintSelf(std::ostream& os, Indent indent) const;
00278 
00282   void GenerateInputRequestedRegion() ;
00283 
00285   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00286 
00288   void DeterminePermutationsAndFlips(const SpatialOrientation::ValidCoordinateOrientationFlags fixed_orient,
00289                                      const SpatialOrientation::ValidCoordinateOrientationFlags moving_orient);
00290   bool NeedToPermute();
00291   bool NeedToFlip();
00293 
00294 
00297   void GenerateData();
00298 
00299 
00300 private:
00301   OrientImageFilter(const Self&); //purposely not implemented
00302   void operator=(const Self&); //purposely not implemented
00303 
00304   std::string GetMajorAxisFromPatientRelativeDirectionCosine(double x, double y, double z);
00305 
00306   CoordinateOrientationCode m_GivenCoordinateOrientation;
00307   CoordinateOrientationCode m_DesiredCoordinateOrientation;
00308   bool                      m_UseImageDirection;
00309 
00310   PermuteOrderArrayType     m_PermuteOrder;
00311   FlipAxesArrayType         m_FlipAxes;
00312   
00313   std::map<std::string,CoordinateOrientationCode> m_StringToCode;
00314   std::map<CoordinateOrientationCode,std::string> m_CodeToString;
00315 
00316 } ; // end of class
00317 
00318 } // end namespace itk
00319 
00320 #ifndef ITK_MANUAL_INSTANTIATION
00321 #include "itkOrientImageFilter.txx"
00322 #endif
00323 
00324 #endif
00325 
00326 
00327 

Generated at Mon Apr 14 13:53:35 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000