From ae2fd017cec9dc939c314e49718abcdad161968c Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Wed, 24 Jul 2013 13:29:54 +0200 Subject: [PATCH] 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 --- itk/clitkResampleImageWithOptionsFilter.txx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) -- 2.47.1