ANTsPy icon indicating copy to clipboard operation
ANTsPy copied to clipboard

Troubles in converting ANTsImage to PIL image.

Open gentlezr opened this issue 2 years ago • 1 comments

Describe the bug Hi, I have troubles in converting ANTsImage to PIL image. Please run this scripts and you can find that 'fixA2.png' is different to 'A.png' or 'fixA1.png'. It shows that ants.to_file() have some tricks I don't know.

`from PIL import Image import numpy as np import ants

path = 'A.png' to_dir = '.' img = ants.from_numpy(np.array(Image.open(path)))

Image.fromarray(np.array(img.numpy())).save(os.path.join(to_dir, 'fixA1.png')) img.to_file(os.path.join(to_dir, 'fixA2.png'))`

A.png A

fixA1.png image

fixA2.png image

gentlezr avatar Jun 16 '22 08:06 gentlezr