opencv-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()

二维数组代表一幅灰度图像。

 

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()

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()

随机数建立灰度图像。

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()

建立彩色的随机数图像。

上一篇:【全开源无加密】迅狐代购商城源码,海关报关对接,语言包支持十几种语言


下一篇:OpenCV查找图像中的轮廓并且展示- 查找轮廓随机用不同的颜色画出