ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkWarpVectorImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkWarpVectorImageFilter_h
00019 #define __itkWarpVectorImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkVectorLinearInterpolateImageFunction.h"
00023 #include "itkPoint.h"
00024 #include "itkFixedArray.h"
00025 
00026 namespace itk
00027 {
00087 template<
00088   class TInputImage,
00089   class TOutputImage,
00090   class TDisplacementField
00091   >
00092 class ITK_EXPORT WarpVectorImageFilter:
00093   public ImageToImageFilter< TInputImage, TOutputImage >
00094 {
00095 public:
00097   typedef WarpVectorImageFilter                           Self;
00098   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00099   typedef SmartPointer< Self >                            Pointer;
00100   typedef SmartPointer< const Self >                      ConstPointer;
00101 
00103   itkNewMacro(Self);
00104 
00106   itkTypeMacro(WarpVectorImageFilter, ImageToImageFilter);
00107 
00109   typedef typename TOutputImage::RegionType OutputImageRegionType;
00110 
00112   typedef typename Superclass::InputImageType         InputImageType;
00113   typedef typename Superclass::InputImagePointer      InputImagePointer;
00114   typedef typename Superclass::OutputImageType        OutputImageType;
00115   typedef typename Superclass::OutputImagePointer     OutputImagePointer;
00116   typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
00117 
00118   typedef typename OutputImageType::IndexType            IndexType;
00119   typedef typename OutputImageType::SizeType             SizeType;
00120   typedef typename OutputImageType::PixelType            PixelType;
00121   typedef typename OutputImageType::SpacingType          SpacingType;
00122   typedef typename OutputImageType::PixelType::ValueType ValueType;
00123 
00125   itkStaticConstMacro(ImageDimension, unsigned int,
00126                       TOutputImage::ImageDimension);
00127 
00129   itkStaticConstMacro(PixelDimension, unsigned int,
00130                       PixelType::Dimension);
00131 
00133   typedef TDisplacementField                        DisplacementFieldType;
00134   typedef typename DisplacementFieldType::Pointer   DisplacementFieldPointer;
00135   typedef typename DisplacementFieldType::PixelType DisplacementType;
00136 
00137 #ifdef ITKV3_COMPATIBILITY
00138   typedef TDisplacementField                       DeformationFieldType;
00139   typedef typename DeformationFieldType::Pointer   DeformationFieldPointer;
00140   typedef typename DeformationFieldType::PixelType DeformationType;
00141 #endif
00142 
00144   typedef double                                                         CoordRepType;
00145   typedef VectorInterpolateImageFunction< InputImageType, CoordRepType > InterpolatorType;
00146   typedef typename InterpolatorType::Pointer                             InterpolatorPointer;
00147   typedef VectorLinearInterpolateImageFunction< InputImageType, CoordRepType >
00148   DefaultInterpolatorType;
00149 
00151   typedef Point< CoordRepType, itkGetStaticConstMacro(ImageDimension) > PointType;
00152 
00154   typedef typename TOutputImage::DirectionType DirectionType;
00155 
00157   void SetDisplacementField(const DisplacementFieldType *field);
00158 
00160   void SetDisplacementField(DisplacementFieldType *field);
00161 
00163   DisplacementFieldType * GetDisplacementField(void);
00164 
00165 #ifdef ITKV3_COMPATIBILITY
00166   void SetDeformationField(const DeformationFieldType *field)
00167   {
00168     this->SetDisplacementField(field);
00169   }
00170 
00171   void SetDeformationField(DeformationFieldType *field)
00172   {
00173     this->SetDisplacementField(field);
00174   }
00175 
00176   DeformationFieldType * GetDeformationField(void)
00177   {
00178     return static_cast<DeformationFieldType *> (GetDisplacementField());
00179   }
00180 #endif
00181 
00183   itkSetObjectMacro(Interpolator, InterpolatorType);
00184 
00186   itkGetObjectMacro(Interpolator, InterpolatorType);
00187 
00189   itkSetMacro(OutputSpacing, SpacingType);
00190   virtual void SetOutputSpacing(const double *values);
00192 
00194   itkGetConstReferenceMacro(OutputSpacing, SpacingType);
00195 
00197   itkSetMacro(OutputOrigin, PointType);
00198   virtual void SetOutputOrigin(const double *values);
00200 
00202   itkGetConstReferenceMacro(OutputOrigin, PointType);
00203 
00205   itkSetMacro(OutputDirection, DirectionType);
00206   itkGetConstReferenceMacro(OutputDirection, DirectionType);
00208 
00210   itkSetMacro(EdgePaddingValue, PixelType);
00211 
00213   itkGetConstMacro(EdgePaddingValue, PixelType);
00214 
00220   virtual void GenerateOutputInformation();
00221 
00228   virtual void GenerateInputRequestedRegion();
00229 
00232   virtual void BeforeThreadedGenerateData();
00233 
00234 #ifdef ITK_USE_CONCEPT_CHECKING
00235 
00236   itkConceptMacro( InputHasNumericTraitsCheck,
00237                    ( Concept::HasNumericTraits< typename TInputImage::PixelType::ValueType > ) );
00238   itkConceptMacro( OutputHasNumericTraitsCheck,
00239                    ( Concept::HasNumericTraits< ValueType > ) );
00240   itkConceptMacro( DisplacementFieldHasNumericTraitsCheck,
00241                    ( Concept::HasNumericTraits< typename TDisplacementField::PixelType::ValueType > ) );
00242 
00244 #endif
00245 protected:
00246   WarpVectorImageFilter();
00247   ~WarpVectorImageFilter() {}
00248   void PrintSelf(std::ostream & os, Indent indent) const;
00250 
00254   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00255                             ThreadIdType threadId);
00256 
00257 private:
00258   WarpVectorImageFilter(const Self &); //purposely not implemented
00259   void operator=(const Self &);        //purposely not implemented
00260 
00261   PixelType     m_EdgePaddingValue;
00262   SpacingType   m_OutputSpacing;
00263   PointType     m_OutputOrigin;
00264   DirectionType m_OutputDirection;
00265 
00266   InterpolatorPointer m_Interpolator;
00267 };
00268 } // end namespace itk
00269 
00270 #ifndef ITK_MANUAL_INSTANTIATION
00271 #include "itkWarpVectorImageFilter.hxx"
00272 #endif
00273 
00274 #endif
00275