From: Simon Rit Date: Wed, 24 Jul 2013 11:29:54 +0000 (+0200) Subject: When resampling, keeping the same origin seems wrong because the origin X-Git-Tag: v1.4.0~2^2~8^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ae2fd017cec9dc939c314e49718abcdad161968c;p=clitk.git When resampling, keeping the same origin seems wrong because the origin is not the corner of the image but the center of the first pixel --- diff --git a/itk/clitkResampleImageWithOptionsFilter.txx b/itk/clitkResampleImageWithOptionsFilter.txx index a3f88be..ddaa8a0 100644 --- a/itk/clitkResampleImageWithOptionsFilter.txx +++ b/itk/clitkResampleImageWithOptionsFilter.txx @@ -222,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)