// 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 size, can't cope with that" );
+ 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; i<dim; i++) {
if(inputSpacing[i]*m_OutputSpacing[i]<0)
- itkExceptionMacro( << "Input and output spacings don't have the same size, can't cope with that" );
+ itkExceptionMacro( << "Input and output spacings don't have the same signs, can't cope with that" );
// see comment above for the use of floor()
m_OutputSize[i] = (int)floor(inputSize[i]*inputSpacing[i]/m_OutputSpacing[i]);
}
std::cout << "LastDimIsTime = " << m_LastDimensionIsTime << std::endl;
}
+ // Compute origin based on image corner
+ typename FilterType::OriginPointType origin = input->GetOrigin();
+ for(unsigned int i=0; i<OutputImageType::ImageDimension; i++) {
+ origin[i] -= 0.5 * input->GetSpacing()[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)