Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

display np array as image

from PIL import Image
import numpy as np

w, h = 512, 512
data = np.zeros((h, w, 3), dtype=np.uint8)
data[0:256, 0:256] = [255, 0, 0] # red patch in upper left
img = Image.fromarray(data, 'RGB')
img.save('my.png')
img.show()
Comment

PREVIOUS NEXT
Code Example
Python :: save fig plot dataframe 
Python :: how to remove numbers from string in python pandas 
Python :: how do i print the entire array pthon jupyter 
Python :: keras model load 
Python :: filter dataframe columns vy a list of columns 
Python :: how to install numpy 
Python :: python count null values in dataframe 
Python :: pandas - from umeric to string 
Python :: images from opencv displayed in blue 
Python :: random date python 
Python :: python add month datetime 
Python :: how to remember to put a semicolon after your code 
Python :: how to wait in python 
Python :: counter in django template 
Python :: convert json to x-www-form-urlencoded pyhon 
Python :: how to read the first line in a file python 
Python :: if type is string python 
Python :: join list with comma python 
Python :: find table with class beautifulsoup 
Python :: python read file delete first line 
Python :: colab cuda version 
Python :: exception get line number python 
Python :: pandas change dtype to string 
Python :: pytest ignore warnings 
Python :: python random 
Python :: unimport library python 
Python :: python find files recursive 
Python :: python word cloud 
Python :: scroll to element python selenium 
Python :: python read url 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =