# importing the librariesimport cv2
import numpy as np
# creating an array using np.full # 255 is code for white color
array_created = np.full((500,500,3),255, dtype = np.uint8)# displaying the image
cv2.imshow("image", array_created)
Python
输出:
方法2:通过使用np.zeroes()创建一个数组。
# importing the modulesimport numpy as np
import cv2
# creating array using np.zeroes()
array = np.zeros([500,500,3],
dtype = np.uint8)# setting RGB color values as 255,255,255
array[:,:]=[255,255,255]# displaying the image
cv2.imshow("image", array)