Fuzhiyuan
(hi_world)
July 27, 2022, 3:35am
#1
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 original`

s. 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.
Code:

```
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 tensor`

s.

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?

Fuzhiyuan
(hi_world)
July 27, 2022, 4:38am
#3
hi @ptrblck

```
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)
sitk.WriteImage(flip_img,"D:\\Code\\Deploy\\flipimage.nii.gz")
img_re = torch.flip(img_flip,(0,))
re_numpy = img_re.numpy()
re_img = sitk.GetImageFromArray(re_numpy)
sitk.WriteImage(re_img,"D:\\Code\\Deploy\\reimg.nii.gz")
```

reimg.nii.gz does not look like resampleITK.nii.gz
I am sorry i can not provide the file.