ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkComposeDisplacementFieldsImageFilter_h 00019 #define __itkComposeDisplacementFieldsImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkVectorInterpolateImageFunction.h" 00023 00024 namespace itk 00025 { 00026 00039 template <class TInputImage, class TOutputImage = TInputImage> 00040 class ComposeDisplacementFieldsImageFilter 00041 : public ImageToImageFilter<TInputImage, TOutputImage> 00042 { 00043 public: 00044 typedef ComposeDisplacementFieldsImageFilter Self; 00045 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass; 00046 typedef SmartPointer<Self> Pointer; 00047 typedef SmartPointer<const Self> ConstPointer; 00048 00050 itkNewMacro( Self ); 00051 00053 itkStaticConstMacro( ImageDimension, unsigned int, 00054 TInputImage::ImageDimension ); 00055 00056 typedef TInputImage InputFieldType; 00057 typedef TOutputImage OutputFieldType; 00058 00060 typedef typename OutputFieldType::PixelType PixelType; 00061 typedef typename OutputFieldType::PixelType VectorType; 00062 typedef typename OutputFieldType::RegionType RegionType; 00063 typedef typename OutputFieldType::IndexType IndexType; 00064 00065 typedef typename OutputFieldType::PointType PointType; 00066 typedef typename OutputFieldType::SpacingType SpacingType; 00067 typedef typename OutputFieldType::PointType OriginType; 00068 typedef typename OutputFieldType::SizeType SizeType; 00069 typedef typename OutputFieldType::DirectionType DirectionType; 00070 00072 typedef typename VectorType::ComponentType RealType; 00073 typedef VectorInterpolateImageFunction 00074 <InputFieldType, RealType> InterpolatorType; 00075 00077 itkGetObjectMacro( Interpolator, InterpolatorType ); 00078 00080 void SetDisplacementField( const InputFieldType *field ) 00081 { 00082 itkDebugMacro( "setting displacement field to " << field ); 00083 if ( field != this->GetInput( 0 ) ) 00084 { 00085 this->SetInput( 0, field ); 00086 this->Modified(); 00087 if( !this->m_Interpolator.IsNull() ) 00088 { 00089 this->m_Interpolator->SetInputImage( field ); 00090 } 00091 } 00092 } 00094 00098 const InputFieldType* GetDisplacementField() const 00099 { 00100 return this->GetInput( 0 ); 00101 } 00102 00104 void SetWarpingField( const InputFieldType *field ) 00105 { 00106 itkDebugMacro( "setting warping field to " << field ); 00107 if ( field != this->GetInput( 1 ) ) 00108 { 00109 this->SetInput( 1, field ); 00110 } 00111 } 00113 00117 const InputFieldType* GetWarpingField() const 00118 { 00119 return this->GetInput( 1 ); 00120 } 00121 00122 /* Set the interpolator. */ 00123 virtual void SetInterpolator( InterpolatorType* interpolator ); 00124 00125 protected: 00126 00128 ComposeDisplacementFieldsImageFilter(); 00129 00131 virtual ~ComposeDisplacementFieldsImageFilter(); 00132 00134 void PrintSelf( std::ostream& os, Indent indent ) const; 00135 00137 void BeforeThreadedGenerateData(); 00138 00140 void ThreadedGenerateData( const RegionType &, ThreadIdType ); 00141 00142 private: 00143 ComposeDisplacementFieldsImageFilter( const Self& ); //purposely not implemented 00144 void operator=( const Self& ); //purposely not implemented 00145 00147 typename InterpolatorType::Pointer m_Interpolator; 00148 00149 }; 00150 00151 } // end namespace itk 00152 00153 #ifndef ITK_MANUAL_INSTANTIATION 00154 #include "itkComposeDisplacementFieldsImageFilter.hxx" 00155 #endif 00156 00157 #endif 00158