The below code takes the axial volume as input, applies a 90-degree rotation around the z-axis, and writes the output volume to a 90.nrrd file. In 90. When viewing the NRRD file in the ITK-SNAP app, we can see that certain pixels are black in both coronal and sagittal views. You can see this missing area in the attached output image where I have highlighted those regions using red boxes.
My C++ code:
typedef itk::Image<signed short, 3> ImageType;
itk::Euler3DTransform<double>::Pointer transform = itk::Euler3DTransform<double>::New();
itk::ResampleImageFilter<ImageType, ImageType>::Pointer spinFilter = itk::ResampleImageFilter<ImageType3D, ImageType3D>::New();
auto spacing = image->GetSpacing();
auto origin = image->GetOrigin();
auto imageSize = image->GetLargestPossibleRegion().GetSize();
itk::Index<3> index{ imageSize[0] / 2, imageSize[1] / 2, imageSize[2] / 2 };
itk::Point<double, 3> center; image->TransformIndexToPhysicalPoint(index, center);
spinFilter->SetDefaultPixelValue(-32767);
spinFilter->SetOutputOrigin(origin);
spinFilter->SetSize(imageSize);
spinFilter->SetOutputSpacing(spacing);
spinFilter->SetOutputDirection(image->GetDirection());
transform->SetCenter(center);
transform->SetRotation(thetaX, thetaY, thetaZ);
spinFilter->SetTransform(transform);
spinFilter->SetInput(image);
itk::ImageFileWriter<ImageType>::Pointer writer = itk::ImageFileWriter<ImageType3D>::New();
writer->SetFileName("D:/outs/90.nrrd");
writer->SetInput(spinFilter->GetOutput());
writer->Update();
Code OUTPUT:
But when, instead of rotating using C++ code, if I rotate my axial volume in the ITK-SNAP app, the image is proper, as we can see in the image below.
ITK-SNAP Rotate output:
What might be the issue here.