Hi, I’m trying to resize a 3D image to an specific size, but I’m getting as a result a white image with some black slices.
Here is the code:
sitk::Image imResize3(sitk::Image input, sitk::Image output_size_image)
{
std::vector<unsigned int> new_dims = output_size_image.GetSize();
std::vector<unsigned int> old_dims = input.GetSize();
sitk::AffineTransform affine = sitk::AffineTransform(3);
std::vector<double> affine_matrix = affine.GetMatrix();
affine_matrix[0] = new_dims[0]/old_dims[0];
affine_matrix[4] = new_dims[1]/old_dims[1];
affine_matrix[8] = new_dims[2]/old_dims[2];
affine.SetMatrix(affine_matrix);
sitk::Image resampled_image = sitk::Resample(input, output_size_image, affine, sitk::sitkBSplineResamplerOrder3);
return resampled_image;
}
The function receives the input image, which the user wants to resize, and the output image, which has the target size. The input image has the size: 256x256x26 and the output image has 182x218x182. Both images have spacing of 1.
Here is the input image.
Here is the output image.
So, how can I solve this problem?
Thank you.