ITK  4.6.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< typename TInputImage, typename TOutputImage >
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);
189 
190  inline void SetGivenCoordinateDirection(const typename TInputImage::DirectionType & GivenDirection)
191  {
193  itk::SpatialOrientationAdapter().FromDirectionCosines(GivenDirection) );
194  }
195 
196  itkGetEnumMacro(DesiredCoordinateOrientation, CoordinateOrientationCode);
198 
199  inline void SetDesiredCoordinateDirection(const typename TOutputImage::DirectionType & DesiredDirection)
200  {
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 
237  {
239  }
240 
242  {
244  }
245 
247  {
249  }
250 
258  virtual void GenerateOutputInformation();
259 
260 #ifdef ITK_USE_CONCEPT_CHECKING
261  // Begin concept checking
262  itkConceptMacro( InputConvertibleToOutput,
264  itkConceptMacro( SameDimension,
265  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension),
266  itkGetStaticConstMacro(OutputImageDimension) > ) );
267  itkConceptMacro( DimensionShouldBe3,
268  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension), 3 > ) );
269  // End concept checking
270 #endif
271 
272 protected:
275  void PrintSelf(std::ostream & os, Indent indent) const;
276 
281 
283  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
284 
285 /*** Member functions used by GenerateData: */
288 
289  bool NeedToPermute();
290 
291  bool NeedToFlip();
292 
295  void GenerateData();
296 
297 private:
298  OrientImageFilter(const Self &); //purposely not implemented
299  void operator=(const Self &); //purposely not implemented
300 
301  std::string GetMajorAxisFromPatientRelativeDirectionCosine(double x, double y, double z);
302 
306 
309 
310  std::map< std::string, CoordinateOrientationCode > m_StringToCode;
311  std::map< CoordinateOrientationCode, std::string > m_CodeToString;
312 }; // end of class
313 } // end namespace itk
314 
315 #ifndef ITK_MANUAL_INSTANTIATION
316 #include "itkOrientImageFilter.hxx"
317 #endif
318 
319 #endif
void SetGivenCoordinateDirection(const typename TInputImage::DirectionType &GivenDirection)
SmartPointer< Self > Pointer
OutputImageType::PixelType OutputImagePixelType
InputImageType::RegionType InputImageRegionType
InputImageType::Pointer InputImagePointer
OutputImageType::RegionType OutputImageRegionType
PermuterType::PermuteOrderArrayType PermuteOrderArrayType
static const unsigned int OutputImageDimension
FlipperType::FlipAxesArrayType FlipAxesArrayType
Base class for all process objects that output image data.
Converts SpatialOrientation flags to/from direction cosines.
void SetDesiredCoordinateOrientation(CoordinateOrientationCode newCode)
InputImageType::ConstPointer InputImageConstPointer
void SetGivenCoordinateOrientation(CoordinateOrientationCode newCode)
std::string GetMajorAxisFromPatientRelativeDirectionCosine(double x, double y, double z)
PermuteAxesImageFilter< TInputImage > PermuterType
Permute axes and then flip images as needed to obtain agreement in coordinateOrientation codes...
FlipImageFilter< TInputImage > FlipperType
void DeterminePermutationsAndFlips(const SpatialOrientation::ValidCoordinateOrientationFlags fixed_orient, const SpatialOrientation::ValidCoordinateOrientationFlags moving_orient)
void EnlargeOutputRequestedRegion(DataObject *)
InputImageType::PixelType InputImagePixelType
void SetDesiredCoordinateDirection(const typename TOutputImage::DirectionType &DesiredDirection)
CoordinateOrientationCode m_GivenCoordinateOrientation
std::map< CoordinateOrientationCode, std::string > m_CodeToString
Permutes the image axes according to a user specified order.
CoordinateOrientationCode m_DesiredCoordinateOrientation
Flips an image across user specified axes.
void operator=(const Self &)
virtual void GenerateOutputInformation()
OutputImageType::Pointer OutputImagePointer
PermuteOrderArrayType m_PermuteOrder
SpatialOrientation::ValidCoordinateOrientationFlags CoordinateOrientationCode
Base class for filters that take an image as input and produce an image as output.
void GenerateInputRequestedRegion()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void PrintSelf(std::ostream &os, Indent indent) const
static const unsigned int InputImageDimension
std::map< std::string, CoordinateOrientationCode > m_StringToCode
OutputImageType::ConstPointer OutputImageConstPointer
ImageToImageFilter< TInputImage, TOutputImage > Superclass
#define itkConceptMacro(name, concept)
FlipAxesArrayType m_FlipAxes
SmartPointer< const Self > ConstPointer
Base class for all data objects in ITK.