python
import cv2
import numpy as np
height =160
width = 280
image = np.zeros((height, width),np.uint8)
cv2.imshow('image',image)
cv2.waitKeyEx(0)
cv2.destroyAllWindows()
二维数组代表一幅灰度图像。
python
import cv2
import numpy as np
height = 160
width = 280
image = np.zeros((height,width), np.uint8)
for y in range(0,height,20):
image[y:y+10,:] = 255
cv2.imshow('image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
python
import cv2
import numpy as np
height = 160
width = 280
image = np.random.randint(256,size=[height,width],dtype=np.uint8)
cv2.imshow('image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
随机数建立灰度图像。
python
import cv2
import numpy as np
height = 160
width = 280
image = np.random.randint(256,size=[height,width,3],dtype=np.uint8)
cv2.imshow('image',image)
cv2.waitKey(0)
cv2.destroyAllWindows()
建立彩色的随机数图像。