00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitkInterpolateFilter_h
00012 #define __mitkInterpolateFilter_h
00013
00014 #include "mitkVolumeToVolumeFilter.h"
00015 #include "mitkGlobalRegistrationFramework.h"
00016
00017 #ifndef MITK_REGISTRATION_VER_OOC
00018 #include "mitkVolumeIterator.h"
00019 #else
00020 #include "mitkVolumeIteratorOoC.h"
00021 #endif
00022
00023 #define INVALID_PIXEL 1e10
00024
00025 #define MITK_INTERPOLATION_MAPPING_MODE_FORWARD 0
00026 #define MITK_INTERPOLATION_MAPPING_MODE_INVERSE 1
00027
00039 class MITK_REGISTRATION_API mitkInterpolateFilter : public mitkVolumeToVolumeFilter
00040 {
00041 public:
00042 MITK_TYPE(mitkInterpolateFilter, mitkVolumeToVolumeFilter)
00043 virtual void PrintSelf(ostream &os);
00044
00049 void SetCorrdinates(mitkVolume* coordinates) {m_CoordVolume = coordinates;}
00050
00055 mitkVolume* GetCoordinates();
00056
00066 void SetRegion(const VectorIndexType& r) { m_Region = r; }
00067
00077 void GetRegion(int r[6]) {for(int i=0; i<6; i++) r[i] = m_Region[i];}
00078
00082 virtual void Update();
00083
00092 virtual bool InterpolatePoint(float x, float y, float z, float &value);
00093
00102 virtual bool InterpolatePoint(float x, float y, float z, float* value);
00103
00110 virtual bool InterpolatePoint(const VectorParameterType & index, ScalarPixelType &value);
00111
00118 virtual bool InterpolatePoint(const VectorParameterType & index, VectorPixelType & value);
00119
00124 void SetOutputDatatype(int dataType) {m_OutputDataType = dataType;}
00125
00130 void SetDefaultPixelValue(ScalarPixelType val) { m_DefaultPixelValue = val; }
00131
00132 void SetMinOutputValue(ScalarPixelType val) { m_MinOutputValue = val; }
00133
00134 void SetMaxOutputValue(ScalarPixelType val) { m_MaxOutputValue = val; }
00135
00136 bool IsOutsideInterpolateRegion(const VectorParameterType & index);
00137
00138 bool IsOutsideInterpolateRegion(ScalarParameterType* index);
00139
00140 protected:
00141 mitkInterpolateFilter();
00142 virtual ~mitkInterpolateFilter();
00143
00144 virtual bool Execute();
00145 virtual void _interpolation(const ScalarParameterType* index, ScalarPixelType* value) = 0;
00146 virtual void _interpolation(const ScalarParameterType* index, ScalarPixelType& value) = 0;
00147
00148 mitkRCPtr<mitkVolume> m_CoordVolume;
00149 mitkVolumeIteratorBase* m_InputIterator;
00150
00151 unsigned int m_NumberOfChannels;
00152 unsigned int m_ImageDimension;
00153 VectorIndexType m_Region;
00154 int m_Dimensions[3];
00155 float m_Spacings[3];
00156
00157 int m_OutputDataType;
00158
00159 ScalarPixelType m_DefaultPixelValue;
00160 ScalarPixelType m_MinOutputValue;
00161 ScalarPixelType m_MaxOutputValue;
00162
00163 private:
00164 mitkInterpolateFilter(const mitkInterpolateFilter&);
00165 void operator = (const mitkInterpolateFilter&);
00166
00167 };
00168
00169 inline bool mitkInterpolateFilter::IsOutsideInterpolateRegion(const VectorParameterType & index)
00170 {
00171 for(unsigned int i=0; i<m_ImageDimension; i++)
00172 {
00173 if(index[i] < 0) return true;
00174 if(index[i] >= (double) m_Dimensions[i] - 1) return true;
00175 }
00176
00177 return false;
00178 }
00179
00180 inline bool mitkInterpolateFilter::IsOutsideInterpolateRegion(ScalarParameterType* index)
00181 {
00182 for(unsigned int i=0; i<m_ImageDimension; i++)
00183 {
00184 if(index[i] < 0) return true;
00185 if(index[i] >= (double) m_Dimensions[i] - 1) return true;
00186 }
00187
00188 return false;
00189 }
00190
00191
00192
00193
00194
00195
00196 #endif
00197