Hi
I am trying to translate a DICOM image using an affine transform to a new position, but when I compare the centers of both images (before/after) it seems like the image did not move. Following is the code I use:
...
auto shearedImage = shearResampler->GetOutput();
ImageType::PointType newVolumeCenter;
shearedImage->TransformContinuousIndexToPhysicalPoint(indx, newVolumeCenter);
// volumeCenter is the oroginal volume's cener
// newVolumeCenter is the canter after I manipulated the original volume
const auto diffCenter = volumeCenter - newVolumeCenter;
itk::AffineTransform<double, 3>::Pointer transformTranslate = itk::AffineTransform<double, 3>::New();
transformTranslate->SetCenter(volumeCenter);
transformTranslate->Translate(diffCenter);
itk::ResampleImageFilter<ImageType, ImageType>::Pointer translateResampler =
itk::ResampleImageFilter<ImageType, ImageType>::New();
translateResampler->SetInput(shearedImage);
translateResampler->SetDefaultPixelValue(-1000.0);
translateResampler->SetSize(size);
translateResampler->SetOutputOrigin(origin);
translateResampler->SetOutputSpacing(spacing);
translateResampler->SetOutputDirection(direction);
translateResampler->SetTransform(transformTranslate);
shearResampler->SetInterpolator(itk::LinearInterpolateImageFunction<ImageType>::New());
translateResampler->Update();
auto translatedImage = translateResampler->GetOutput();
What am I doing wrong?
Thank you