Tiff image to Numpy array


In [ ]:
import numpy as np
from PIL import Image

In [ ]:
img_path = "full_tif256.tif"

In [ ]:
im = Image.open(img_path)
#im.show()

In [ ]:
imnb = im.convert("L")

In [ ]:
a = np.array(imnb)
a

In [ ]:
a.min(), a.max(), a.shape

In [ ]:
np.save("galaxy.npy", a)

In [ ]:
!ls -lh galaxy.npy

In [ ]:
a2 = np.load("galaxy.npy")

In [ ]:
plt.imshow(a2);