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

建立彩色的随机数图像。

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-13 14:22:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-13 14:22:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-13 14:22:01       87 阅读
  4. Python语言-面向对象

    2024-06-13 14:22:01       96 阅读

热门阅读

  1. MySQL为何不支持函数索引的使用

    2024-06-13 14:22:01       29 阅读
  2. 沙普利值是什么,和沙普利值相结合的更好办法

    2024-06-13 14:22:01       28 阅读
  3. 机械培训元宇宙 - 开启技术技能学习的全新维度

    2024-06-13 14:22:01       36 阅读
  4. iOS 18支持的设备列表

    2024-06-13 14:22:01       28 阅读
  5. 工作笔记1--服务器pytorch安装报Read timed out问题

    2024-06-13 14:22:01       35 阅读
  6. Oracle数据库面试题-11

    2024-06-13 14:22:01       26 阅读