X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkResampleImageWithOptionsFilter.txx;h=4c949cec33eff1ade7b4fe43cfac3f4bf313a1fe;hb=7ae042efea7b958dc573948b4e27981bafa9957e;hp=7c05dc5b018644848ded74469216017e23b3769a;hpb=ff7b62d284bd4f5eadce3aff4b217ae722b369a7;p=clitk.git diff --git a/itk/clitkResampleImageWithOptionsFilter.txx b/itk/clitkResampleImageWithOptionsFilter.txx index 7c05dc5..4c949ce 100644 --- a/itk/clitkResampleImageWithOptionsFilter.txx +++ b/itk/clitkResampleImageWithOptionsFilter.txx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ + ===========================================================================**/ // clitk #include "clitkDD.h" @@ -37,7 +37,7 @@ //-------------------------------------------------------------------- template clitk::ResampleImageWithOptionsFilter:: -ResampleImageWithOptionsFilter():itk::ImageToImageFilter() +ResampleImageWithOptionsFilter():itk::ImageToImageFilter() { static const unsigned int dim = InputImageType::ImageDimension; this->SetNumberOfRequiredInputs(1); @@ -54,7 +54,10 @@ ResampleImageWithOptionsFilter():itk::ImageToImageFilter void clitk::ResampleImageWithOptionsFilter:: -SetInput(const InputImageType * image) +SetInput(const InputImageType * image) { // Process object is not const-correct so the const casting is required. this->SetNthInput(0, const_cast(image)); @@ -75,7 +78,7 @@ SetInput(const InputImageType * image) template void clitk::ResampleImageWithOptionsFilter:: -GenerateInputRequestedRegion() +GenerateInputRequestedRegion() { // call the superclass's implementation of this method Superclass::GenerateInputRequestedRegion(); @@ -96,7 +99,7 @@ GenerateInputRequestedRegion() template void clitk::ResampleImageWithOptionsFilter:: -GenerateOutputInformation() +GenerateOutputInformation() { static const unsigned int dim = InputImageType::ImageDimension; @@ -121,19 +124,31 @@ GenerateOutputInformation() if (m_OutputIsoSpacing != -1) { // apply isoSpacing for(unsigned int i=0; iGetOutput(0); // OutputImageRegionType region; @@ -179,28 +194,20 @@ GenerateOutputInformation() //-------------------------------------------------------------------- template -void +void clitk::ResampleImageWithOptionsFilter:: -GenerateData() +GenerateData() { - + // Get input pointer InputImagePointer input = dynamic_cast(itk::ProcessObject::GetInput(0)); 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); - // Create main Resample Image Filter typedef itk::ResampleImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); filter->GraftOutput(this->GetOutput()); - // this->GetOutput()->Print(std::cout); this->GetOutput()->SetBufferedRegion(this->GetOutput()->GetLargestPossibleRegion()); - // this->GetOutput()->Print(std::cout); // Print options if needed if (m_VerboseOptions) { @@ -221,15 +228,21 @@ GenerateData() std::cout << "LastDimIsTime = " << m_LastDimensionIsTime << std::endl; } + // Compute origin based on image corner + for(unsigned int i=0; iGetSpacing()[i]; + m_OutputOrigin[i] += 0.5 * m_OutputSpacing[i]; + } + // Instance of the transform object to be passed to the resample // filter. By default, identity transform is applied filter->SetTransform(m_Transform); filter->SetSize(m_OutputSize); filter->SetOutputSpacing(m_OutputSpacing); - filter->SetOutputOrigin(input->GetOrigin()); + filter->SetOutputOrigin(m_OutputOrigin); filter->SetDefaultPixelValue(m_DefaultPixelValue); - filter->SetNumberOfThreads(this->GetNumberOfThreads()); - filter->SetOutputDirection(input->GetDirection()); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example) + filter->SetNumberOfThreads(this->GetNumberOfThreads()); + filter->SetOutputDirection(m_OutputDirection); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example) // Select interpolator switch (m_InterpolationType) { @@ -296,21 +309,16 @@ GenerateData() filter->Update(); // Set output - // DD("before Graft"); - - //this->GraftOutput(filter->GetOutput()); - this->SetNthOutput(0, filter->GetOutput()); - - // DD("after Graft"); + this->GraftOutput(filter->GetOutput()); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template -typename InputImageType::Pointer -clitk::ResampleImageSpacing(typename InputImageType::Pointer input, - typename InputImageType::SpacingType spacing, +typename InputImageType::Pointer +clitk::ResampleImageSpacing(typename InputImageType::Pointer input, + typename InputImageType::SpacingType spacing, int interpolationType) { typedef clitk::ResampleImageWithOptionsFilter ResampleFilterType;