00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
00163
00165 typedef PermuteAxesImageFilter< TInputImage > PermuterType;
00166 typedef typename PermuterType::PermuteOrderArrayType PermuteOrderArrayType;
00167
00169 typedef FlipImageFilter< TInputImage > FlipperType;
00170 typedef typename FlipperType::FlipAxesArrayType FlipAxesArrayType;
00171
00172
00174 itkStaticConstMacro(InputImageDimension, unsigned int,
00175 TInputImage::ImageDimension);
00176 itkStaticConstMacro(OutputImageDimension, unsigned int,
00177 TOutputImage::ImageDimension);
00179
00181 itkNewMacro(Self);
00182
00184 itkTypeMacro(OrientImageFilter, ImageToImageFilter);
00185
00187 itkGetMacro(GivenCoordinateOrientation, CoordinateOrientationCode);
00188 void SetGivenCoordinateOrientation(CoordinateOrientationCode newCode);
00189 itkGetMacro(DesiredCoordinateOrientation, CoordinateOrientationCode);
00190 void SetDesiredCoordinateOrientation(CoordinateOrientationCode newCode);
00192
00200 itkBooleanMacro(UseImageDirection);
00201 itkGetMacro(UseImageDirection, bool);
00202 itkSetMacro(UseImageDirection, bool);
00204
00206 itkGetConstReferenceMacro( PermuteOrder, PermuteOrderArrayType );
00207
00209 itkGetConstReferenceMacro( FlipAxes, FlipAxesArrayType );
00210
00224 void SetDesiredCoordinateOrientationToAxial ()
00225 {
00226 this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
00227 }
00228 void SetDesiredCoordinateOrientationToCoronal ()
00229 {
00230 this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA);
00231 }
00232 void SetDesiredCoordinateOrientationToSagittal ()
00233 {
00234 this->SetDesiredCoordinateOrientation (SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASL);
00235 }
00237
00245 virtual void GenerateOutputInformation();
00246
00247 #ifdef ITK_USE_CONCEPT_CHECKING
00248
00249 itkConceptMacro(InputConvertibleToOutput,
00250 (Concept::Convertible<InputImagePixelType, OutputImagePixelType>));
00251 itkConceptMacro(SameDimension,
00252 (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),itkGetStaticConstMacro(OutputImageDimension)>));
00253 itkConceptMacro(DimensionShouldBe3,
00254 (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),3>));
00255
00257 #endif
00258
00259 protected:
00260 OrientImageFilter();
00261 ~OrientImageFilter() {};
00262 void PrintSelf(std::ostream& os, Indent indent) const;
00263
00267 void GenerateInputRequestedRegion() ;
00268
00270 void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00271
00273 void DeterminePermutationsAndFlips(const SpatialOrientation::ValidCoordinateOrientationFlags fixed_orient,
00274 const SpatialOrientation::ValidCoordinateOrientationFlags moving_orient);
00275 bool NeedToPermute();
00276 bool NeedToFlip();
00278
00279
00282 void GenerateData();
00283
00284
00285 private:
00286 OrientImageFilter(const Self&);
00287 void operator=(const Self&);
00288
00289 std::string GetMajorAxisFromPatientRelativeDirectionCosine(double x, double y, double z);
00290
00291 CoordinateOrientationCode m_GivenCoordinateOrientation;
00292 CoordinateOrientationCode m_DesiredCoordinateOrientation;
00293 bool m_UseImageDirection;
00294
00295 PermuteOrderArrayType m_PermuteOrder;
00296 FlipAxesArrayType m_FlipAxes;
00297
00298 std::map<std::string,CoordinateOrientationCode> m_StringToCode;
00299 std::map<CoordinateOrientationCode,std::string> m_CodeToString;
00300
00301 } ;
00302
00303 }
00304
00305 #ifndef ITK_MANUAL_INSTANTIATION
00306 #include "itkOrientImageFilter.txx"
00307 #endif
00308
00309 #endif
00310
00311
00312