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: 2005/09/12 16:06:39 $
00007 Version:   $Revision: 1.5 $
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 <map>
00026 #include <string>
00027 
00028 namespace itk {
00029 
00138 template<class TInputImage, class TOutputImage>
00139 class ITK_EXPORT OrientImageFilter :
00140     public ImageToImageFilter<TInputImage, TOutputImage>
00141 {
00142 public:
00144   typedef OrientImageFilter Self;
00145   typedef ImageToImageFilter<TInputImage, TOutputImage>
00146   Superclass;
00147   typedef SmartPointer<Self>        Pointer;
00148   typedef SmartPointer<const Self>  ConstPointer;
00149 
00151   typedef TInputImage InputImageType;
00152   typedef TOutputImage OutputImageType;
00153   typedef typename InputImageType::Pointer         InputImagePointer;
00154   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00155   typedef typename InputImageType::RegionType      InputImageRegionType;
00156   typedef typename InputImageType::PixelType       InputImagePixelType;
00157   typedef typename OutputImageType::Pointer        OutputImagePointer;
00158   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00159   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00160   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00161   typedef SpatialOrientation::ValidCoordinateOrientationFlags
00162   CoordinateOrientationCode;
00164   typedef PermuteAxesImageFilter< TInputImage > PermuterType;
00165   typedef typename PermuterType::PermuteOrderArrayType PermuteOrderArrayType;
00166 
00168   typedef FlipImageFilter< TInputImage > FlipperType;
00169   typedef typename FlipperType::FlipAxesArrayType  FlipAxesArrayType;
00170 
00171   
00173   itkStaticConstMacro(InputImageDimension, unsigned int,
00174                       TInputImage::ImageDimension);
00175   itkStaticConstMacro(OutputImageDimension, unsigned int,
00176                       TOutputImage::ImageDimension);
00177 
00180   itkConceptMacro(SameDimension,
00181     (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),itkGetStaticConstMacro(OutputImageDimension)>));
00182 
00184   itkConceptMacro(DimensionShouldBe3,
00185     (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),3>));
00186 
00188   itkNewMacro(Self);
00189 
00191   itkTypeMacro(OrientImageFilter, ImageToImageFilter);
00192 
00194   itkGetMacro(GivenCoordinateOrientation, CoordinateOrientationCode);
00195   void SetGivenCoordinateOrientation(CoordinateOrientationCode newCode);
00196   itkGetMacro(DesiredCoordinateOrientation, CoordinateOrientationCode);
00197   void SetDesiredCoordinateOrientation(CoordinateOrientationCode newCode);
00198 
00206   itkBooleanMacro(UseImageDirection);
00207   itkGetMacro(UseImageDirection, bool);
00208   itkSetMacro(UseImageDirection, bool);
00209 
00211   itkGetConstReferenceMacro( PermuteOrder, PermuteOrderArrayType );
00212 
00214   itkGetConstReferenceMacro( FlipAxes, FlipAxesArrayType );
00215 
00229   void SetDesiredCoordinateOrientationToAxial ()
00230     {
00231    this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
00232     }
00233   void SetDesiredCoordinateOrientationToCoronal ()
00234     {
00235     this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA);
00236     }
00237   void SetDesiredCoordinateOrientationToSagittal ()
00238     {
00239     this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASL);
00240     }
00241 
00249   virtual void GenerateOutputInformation();
00250 
00251 protected:
00252   OrientImageFilter();
00253   ~OrientImageFilter() {};
00254   void PrintSelf(std::ostream& os, Indent indent) const;
00255 
00259   void GenerateInputRequestedRegion() ;
00260 
00262   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00263 
00264   /*** Member functions used by GenerateData: */
00265   void DeterminePermutationsAndFlips(const SpatialOrientation::ValidCoordinateOrientationFlags fixed_orient,
00266                                      const SpatialOrientation::ValidCoordinateOrientationFlags moving_orient);
00267   bool NeedToPermute();
00268   bool NeedToFlip();
00269 
00270 
00273   void GenerateData();
00274 
00275 
00276 private:
00277   OrientImageFilter(const Self&); //purposely not implemented
00278   void operator=(const Self&); //purposely not implemented
00279 
00280   std::string GetMajorAxisFromPatientRelativeDirectionCosine(double x, double y, double z);
00281 
00282   CoordinateOrientationCode m_GivenCoordinateOrientation;
00283   CoordinateOrientationCode m_DesiredCoordinateOrientation;
00284   bool                      m_UseImageDirection;
00285 
00286   PermuteOrderArrayType     m_PermuteOrder;
00287   FlipAxesArrayType         m_FlipAxes;
00288   
00289   std::map<std::string,CoordinateOrientationCode> m_StringToCode;
00290   std::map<CoordinateOrientationCode,std::string> m_CodeToString;
00291 
00292 } ; // end of class
00293 
00294 } // end namespace itk
00295 
00296 #ifndef ITK_MANUAL_INSTANTIATION
00297 #include "itkOrientImageFilter.txx"
00298 #endif
00299 
00300 #endif
00301 
00302 

Generated at Wed May 24 23:48:58 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000