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

建立彩色的随机数图像。

相关推荐
李航198311 分钟前
给自己的图形引擎,配上了AI渲染,做设计真是太方便了
人工智能·python·计算机视觉·ai·ai编程
L@ncor13 分钟前
第六章 框架开发实践 · 学习笔记(AutoGen / AgentScope / CAMEL / LangGraph)
python·框架·autogen·langgraph·agentscope
Zhou14113621 分钟前
SpringSecurity_02_授权与高级功能
开发语言·python
码匠许师傅1 小时前
【C++三方组件】cpp-httplib:一个头文件起 HTTP 服务
开发语言·c++·http
摇滚侠2 小时前
《On Java 中文版 基础卷》阅读笔记 对象无处不在 03
java·笔记·python
小小小小钰儿2 小时前
1.5-Python网络编程
开发语言·网络·python·web安全·计算机·网络安全
hiahiahia1232 小时前
实现完整 Tool Dispatcher
开发语言·前端
keke.shengfengpolang2 小时前
2026年金融风控岗技术能力拆解:SQL取数、Python建模、评分卡项目,校招面试到底考什
python