Quantcast
Channel: How to convert a NumPy array to PIL image applying matplotlib colormap - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by aravinda_gn for How to convert a NumPy array to PIL image applying matplotlib colormap

$
0
0
  • input = numpy_image

  • np.uint8 -> converts to integers

  • convert('RGB') -> converts to RGB

  • Image.fromarray -> returns an image object

      from PIL import Image  import numpy as np  PIL_image = Image.fromarray(np.uint8(numpy_image)).convert('RGB')  PIL_image = Image.fromarray(numpy_image.astype('uint8'), 'RGB')

Viewing all articles
Browse latest Browse all 4

Trending Articles