X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkResampleImageWithOptionsFilter.txx;h=8e709d8c29dc9f10818d5daffdfffc82dfceeddd;hb=44ebb81a500e42cf19964d209e14a59812a0dd4d;hp=aa09f7129812ce2cc3065e85925d5d09faac173f;hpb=d8e6a6c0b380c2e7b542a2b9d922dc982a3d0d85;p=clitk.git diff --git a/itk/clitkResampleImageWithOptionsFilter.txx b/itk/clitkResampleImageWithOptionsFilter.txx index aa09f71..8e709d8 100644 --- a/itk/clitkResampleImageWithOptionsFilter.txx +++ b/itk/clitkResampleImageWithOptionsFilter.txx @@ -35,9 +35,9 @@ #include "itkCommand.h" //-------------------------------------------------------------------- -template -clitk::ResampleImageWithOptionsFilter:: -ResampleImageWithOptionsFilter():itk::ImageToImageFilter() +template +clitk::ResampleImageWithOptionsFilter:: +ResampleImageWithOptionsFilter():itk::ImageToImageFilter() { static const unsigned int dim = InputImageType::ImageDimension; this->SetNumberOfRequiredInputs(1); @@ -60,9 +60,9 @@ ResampleImageWithOptionsFilter():itk::ImageToImageFilter +template void -clitk::ResampleImageWithOptionsFilter:: +clitk::ResampleImageWithOptionsFilter:: SetInput(const InputImageType * image) { // Process object is not const-correct so the const casting is required. @@ -72,9 +72,9 @@ SetInput(const InputImageType * image) //-------------------------------------------------------------------- -template +template void -clitk::ResampleImageWithOptionsFilter:: +clitk::ResampleImageWithOptionsFilter:: GenerateInputRequestedRegion() { // call the superclass's implementation of this method @@ -82,7 +82,7 @@ GenerateInputRequestedRegion() // get pointers to the input and output InputImagePointer inputPtr = - const_cast< TInputImage *>( this->GetInput() ); + const_cast< InputImageType *>( this->GetInput() ); // Request the entire input image InputImageRegionType inputRegion; @@ -93,9 +93,9 @@ GenerateInputRequestedRegion() //-------------------------------------------------------------------- -template +template void -clitk::ResampleImageWithOptionsFilter:: +clitk::ResampleImageWithOptionsFilter:: GenerateOutputInformation() { static const unsigned int dim = InputImageType::ImageDimension; @@ -178,9 +178,9 @@ GenerateOutputInformation() //-------------------------------------------------------------------- -template +template void -clitk::ResampleImageWithOptionsFilter:: +clitk::ResampleImageWithOptionsFilter:: GenerateData() { @@ -189,6 +189,7 @@ GenerateData() static const unsigned int dim = InputImageType::ImageDimension; // Set regions and allocate + //DD(this->GetOutput()->GetLargestPossibleRegion()); //this->GetOutput()->SetRegions(m_OutputRegion); //this->GetOutput()->Allocate(); // this->GetOutput()->FillBuffer(m_DefaultPixelValue); @@ -198,7 +199,7 @@ GenerateData() typename FilterType::Pointer filter = FilterType::New(); filter->GraftOutput(this->GetOutput()); // this->GetOutput()->Print(std::cout); - // this->GetOutput()->SetBufferedRegion(this->GetOutput()->GetLargestPossibleRegion()); + this->GetOutput()->SetBufferedRegion(this->GetOutput()->GetLargestPossibleRegion()); // this->GetOutput()->Print(std::cout); // Print options if needed @@ -303,3 +304,30 @@ GenerateData() // DD("after Graft"); } //-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +typename InputImageType::Pointer +clitk::ResampleImageSpacing(typename InputImageType::Pointer input, + typename InputImageType::SpacingType spacing, + int interpolationType) +{ + typedef clitk::ResampleImageWithOptionsFilter ResampleFilterType; + typename ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + resampler->SetInput(input); + resampler->SetOutputSpacing(spacing); + typename ResampleFilterType::InterpolationTypeEnumeration inter=ResampleFilterType::NearestNeighbor; + switch(interpolationType) { + case 0: inter = ResampleFilterType::NearestNeighbor; break; + case 1: inter = ResampleFilterType::Linear; break; + case 2: inter = ResampleFilterType::BSpline; break; + case 3: inter = ResampleFilterType::B_LUT; break; + case 4: inter = ResampleFilterType::WSINC; break; + } + resampler->SetInterpolationType(inter); + resampler->SetGaussianFilteringEnabled(true); + resampler->Update(); + return resampler->GetOutput(); +} +//--------------------------------------------------------------------