How to create a white image in Python?

Every color in an image is represented by one byte. So to create an image array, you should set it’s dtype to uint8.

And, you don’t need for-loop to set every elements to 255, you can use fill() method or slice index:

import numpy as np
img = np.zeros([100,100,3],dtype=np.uint8)
img.fill(255) # or img[:] = 255

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)