0

I have a gray scale image of type uint16, size = (256,256) ndarray object

I want to use PIL to resize it to (75,75) but it requires the input to be of Image type.

How can I convert image of ndarray object into Image type to use image.resize((75,75), Image.ANTIALIAS)

NOTE: I know I can read image using Image.open if it is saved, but my image is obtained after some image processing steps and is not read from disk

UPDATE: I am trying to provide image that I have :

import scipy.misc
scipy.misc.imsave('image.png', box_img)

enter image description here

# read this similar format image of type ndarray    
image = scipy.ndimage.imread('image.png')
# convert it to Image type

The image attached when read of similar type as I need. I need to convert this image into Image type

Thanks,

Gopi

Gopi
  • 369
  • 1
  • 17

1 Answers1

3
from PIL import Image
import numpy as np

# An array of ones for example
img_array = np.ones((256,256), dtype='uint16')
img = Image.fromarray(img_array)
img = img.resize((75,75))
Matan Hugi
  • 1,110
  • 8
  • 16