opencv-python(八)

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

建立彩色的随机数图像。

相关推荐
℃CCCC12 小时前
请求库-axios
开发语言·华为·网络请求·harmonyos·deveco studio·axios请求·arkts编程
ling__i13 小时前
java day18
java·开发语言
矛取矛求13 小时前
日期类的实现
开发语言·c++·算法
大翻哥哥13 小时前
Python 2025:AI工程化与智能代理开发实战
开发语言·人工智能·python
站大爷IP13 小时前
Python文件处理:从基础操作到实战技巧全解析
python
在下雨59913 小时前
项目讲解1
开发语言·数据结构·c++·算法·单例模式
再努力"亿"点点13 小时前
Sklearn(机器学习)实战:鸢尾花数据集处理技巧
开发语言·python
费弗里13 小时前
无需云服务器!通过Plotly Cloud免费快捷部署Dash应用
python·dash
跟橙姐学代码13 小时前
轻松搞定 Python 模块与包导入:新手也能秒懂的入门指南
前端·python·ipython
饭碗的彼岸one13 小时前
C++ 并发编程:异步任务
c语言·开发语言·c++·后端·c·异步