Hi,
I want to resample the 3D image to (256, 256, 166) if their shapes are different.
Example: (192, 192, 160) to (256, 256, 166)
and (256, 256, 170) to (256, 256, 166) etc
I used the below code to do that(code referred from https://www.kaggle.com/mechaman/resizing-reshaping-and-resampling-nifti-files)
target_img_shape = (256, 256, 166)
if img_shape != target_img_shape:
resampled_nii = resample_img(image, target_affine=np.eye(4) * 2, target_shape=target_img_shape,
interpolation='nearest')
resampled_img_data = resampled_nii.get_fdata()
else:
resampled_img_data = image.get_fdata()
I am getting the required shape but the resultant image is too small. I have the following questions:
- Is the above code is correct
- Is there any other ways to resample the 3D image to the required size ie., (256, 256, 166)
Thank you.