X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkResampleImageWithOptionsFilter.txx;h=ddaa8a077b41f2ffcf2456836c2eeb7a4f0119fc;hb=299afce0c4c4cc3524dccecf4ecffd46d7a66328;hp=1bf5448782819792a906d03aafa0268e3e055a54;hpb=dd96575fcb3e3af28160766907f68e34dfbf1ba2;p=clitk.git diff --git a/itk/clitkResampleImageWithOptionsFilter.txx b/itk/clitkResampleImageWithOptionsFilter.txx index 1bf5448..ddaa8a0 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" @@ -125,11 +125,15 @@ GenerateOutputInformation() // floor() is used to intentionally reduce the number of slices // because, from a clinical point of view, it's better to // remove data than to add data that privously didn't exist. + if(inputSpacing[i]*m_OutputSpacing[i]<0) + itkExceptionMacro( << "Input and output spacings don't have the same signs, can't cope with that" ); m_OutputSize[i] = (int)floor(inputSize[i]*inputSpacing[i]/m_OutputSpacing[i]); } } else { if (m_OutputSpacing[0] != -1) { // apply spacing, compute size for(unsigned int i=0; iGetOutput(0); // OutputImageRegionType region; @@ -218,12 +222,19 @@ GenerateData() std::cout << "LastDimIsTime = " << m_LastDimensionIsTime << std::endl; } + // Compute origin based on image corner + typename FilterType::OriginPointType origin = input->GetOrigin(); + for(unsigned int i=0; iGetSpacing()[i]; + origin[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(origin); 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)