I use torch.flip to flip my file(3d) twice, dim is 0, but the second result
s picture does not the same as the originals. It seems that the first flip is Flipping 180 degrees perpendicular to the screen, and the second flip is flipping 180 degrees horizontally on the screen.
tensor = torch.from_numpy(sitk.GetArrayFromImage(img))
tensor_flip = torch.flip(tensor,(0,))
tensor_flip2 = torch.flip(tensor_flip,(0,))
The point is tensor_flip2
s data is the same as tensor, but the image it represents is different from tensors.
I don’t understand this claim:
data is the same as tensor, but the image it represents is different from tensor`s
Could you describe how the “image” the tensor represents can be different if all values, the shape, and strides match exactly?
Assuming you are trying to plot the image, could you share a code snippet which would reproduce the issue?
img = sitk.ReadImage("D:\\Code\\Deploy\\resampleITK.nii.gz")
img_numpy = sitk.GetArrayFromImage(img)
img_tensor = torch.from_numpy(img_numpy)
img_flip = torch.flip(img_tensor,(0,))
flip_numpy = img_flip.numpy()
flip_img = sitk.GetImageFromArray(flip_numpy)
img_re = torch.flip(img_flip,(0,))
re_numpy = img_re.numpy()
re_img = sitk.GetImageFromArray(re_numpy)
reimg.nii.gz does not look like resampleITK.nii.gz
I am sorry i can not provide the file.