#include <bbitkResampleImageFilter.h>
Private Member Functions | |
BBTK_BLACK_BOX_INTERFACE (ResampleImageFilter, bbtk::AtomicBlackBox) | |
BBTK_DECLARE_INPUT (In, anyImagePointer) | |
BBTK_DECLARE_INPUT (Spacing, std::vector< double >) | |
BBTK_DECLARE_INPUT (Interpolation, std::string) | |
BBTK_DECLARE_OUTPUT (Out, anyImagePointer) | |
BBTK_PROCESS (ProcessSwitch) | |
void | ProcessSwitch () |
template<class T> | |
void | Process () |
void | bbUserConstructor () |
void | bbUserCopyConstructor () |
void | Init () |
Private Attributes | |
itk::Object * | mOutput |
Definition at line 46 of file bbitkResampleImageFilter.h.
bbitk::ResampleImageFilter::BBTK_BLACK_BOX_INTERFACE | ( | ResampleImageFilter | , | |
bbtk::AtomicBlackBox | ||||
) | [private] |
bbitk::ResampleImageFilter::BBTK_DECLARE_INPUT | ( | In | , | |
anyImagePointer | ||||
) | [private] |
bbitk::ResampleImageFilter::BBTK_DECLARE_INPUT | ( | Spacing | , | |
std::vector< double > | ||||
) | [private] |
bbitk::ResampleImageFilter::BBTK_DECLARE_INPUT | ( | Interpolation | , | |
std::string | ||||
) | [private] |
bbitk::ResampleImageFilter::BBTK_DECLARE_OUTPUT | ( | Out | , | |
anyImagePointer | ||||
) | [private] |
bbitk::ResampleImageFilter::BBTK_PROCESS | ( | ProcessSwitch | ) | [private] |
void bbitk::ResampleImageFilter::ProcessSwitch | ( | ) | [inline, private] |
Definition at line 85 of file bbitkResampleImageFilter.h.
References BBTK_TEMPLATE_ITK_IMAGE_SWITCH, and Process().
00086 { 00087 bbtk::TypeInfo t = bbGetInputIn().type(); 00088 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process); 00089 }
void bbitk::ResampleImageFilter::Process | ( | ) | [inline, private] |
Definition at line 92 of file bbitkResampleImageFilter.h.
References mOutput.
Referenced by ProcessSwitch().
00093 { 00094 bbtkDebugMessageInc("Core",9, 00095 "bbitk::ResampleImageFilter::Process<" 00096 <<bbtk::TypeName<T>()<<">()"<<std::endl); 00097 00098 typedef T ImageType; 00099 typedef itk::ResampleImageFilter<ImageType,ImageType> FilterType; 00100 typename FilterType::Pointer filter = FilterType::New(); 00101 const unsigned int Dimension = ImageType::ImageDimension; 00102 00103 // Input 00104 T* in = this->bbGetInputIn().get<T*>(); 00105 filter->SetInput( in ); 00106 00107 // Size, Spacing, Origin and DefaultPixelVal 00108 typename ImageType::SizeType size; 00109 typename ImageType::SpacingType spacing; 00110 typename ImageType::PointType origin; 00111 typename ImageType::RegionType LPR; 00112 LPR = in->GetLargestPossibleRegion(); 00113 size = LPR.GetSize(); 00114 // origin = LPR.GetIndex(); //in->GetOrigin(); 00115 for (unsigned int i=0;i<Dimension;++i) 00116 { 00117 origin[i] = LPR.GetIndex()[i]*in->GetSpacing()[i]; 00118 spacing[i] = bbGetInputSpacing()[i]; 00119 double tmp = (LPR.GetSize()[i]*in->GetSpacing()[i]/spacing[i] ) + 0.5; 00120 size[i] = (long)floor(tmp); 00121 // size[i] = (long)lrint(LPR.GetSize()[i]*in->GetSpacing()[i]/spacing[i]); 00122 } 00123 00124 filter->SetOutputOrigin (origin); 00125 filter->SetSize (size); 00126 filter->SetOutputSpacing( spacing ); 00127 00128 filter->SetDefaultPixelValue (0); 00129 filter->SetOutputDirection( in->GetDirection() ); 00130 00131 00132 00133 // Transform 00134 typedef itk::AffineTransform < double, Dimension> TransformType; 00135 00136 // Instance of the transform object to be passed to the resample filter 00137 // By default, identity transform is applied 00138 typename TransformType::Pointer transform = TransformType::New(); 00139 filter->SetTransform ( transform ); 00140 00141 00142 00143 if ( bbGetInputInterpolation() == "NearestNeighbor" ) { 00144 typedef itk::NearestNeighborInterpolateImageFunction < ImageType, double > InterpolatorType; 00145 // We create an interpolator of the found type 00146 typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); 00147 filter->SetInterpolator( interpolator ); 00148 } 00149 else if ( bbGetInputInterpolation() == "BSpline") { 00150 typedef itk::BSplineInterpolateImageFunction < ImageType, double > InterpolatorType; 00151 // We create an interpolator of the found type 00152 typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); 00153 filter->SetInterpolator(interpolator); 00154 // When handling unsigned data, it is possible that the interpolated value is negative 00155 // if ( (m_InputImage->GetComponentTypeAsString() == "uchar") || 00156 // (m_InputImage->GetComponentTypeAsString() == "ushort") || 00157 // (m_InputImage->GetComponentTypeAsString() == "uint") ) { 00158 // std::cout << "Warning! you're using unsigned data ! The interpolated value may result negative! "<< std::endl; 00159 // } 00160 } //end else if 00161 // Interpolation 00162 else { // if ( bbGetInputInterpolation() == "Linear" ) { 00163 typedef itk::LinearInterpolateImageFunction < ImageType, double > InterpolatorType; 00164 // We create an interpolator of the found type 00165 typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); 00166 filter->SetInterpolator( interpolator ); 00167 } 00168 00169 filter->Update(); 00170 filter->GetOutput()->Register(); 00171 if (mOutput) mOutput->UnRegister(); 00172 this->bbSetOutputOut( filter->GetOutput() ); 00173 mOutput = filter->GetOutput(); 00174 00175 bbtkDebugDecTab("Core",9); 00176 }
void bbitk::ResampleImageFilter::bbUserConstructor | ( | ) | [inline, private] |
void bbitk::ResampleImageFilter::bbUserCopyConstructor | ( | ) | [inline, private] |
void bbitk::ResampleImageFilter::Init | ( | ) | [private] |
Definition at line 179 of file bbitkResampleImageFilter.h.
References mOutput.
Referenced by bbUserConstructor(), and bbUserCopyConstructor().
00180 { 00181 std::vector<double> res; 00182 res.push_back(1); 00183 res.push_back(1); 00184 res.push_back(1); 00185 bbSetInputSpacing(res); 00186 mOutput = 0; 00187 }
itk::Object* bbitk::ResampleImageFilter::mOutput [private] |