Create a white image using NumPy in Python
Let us see how to create a white image using NumPy and cv2. A white image has all its pixels as 255.
Method 1: Using np.full() method :
Python3
import cv2
import numpy as np
array_created = np.full(( 500 , 500 , 3 ),
255 , dtype = np.uint8)
cv2.imshow( "image" , array_created)
|
Output:
Method 2: By creating an array using np.zeroes() :
Python3
import numpy as np
import cv2
array = np.zeros([ 500 , 500 , 3 ],
dtype = np.uint8)
array[:, :] = [ 255 , 255 , 255 ]
cv2.imshow( "image" , array)
|
Output:
Last Updated :
02 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...