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

建立彩色的随机数图像。

相关推荐
半桶水专家1 天前
go语言中的结构体嵌入详解
开发语言·后端·golang
在屏幕前出油1 天前
二、Python面向对象编程基础——理解self
开发语言·python
阿方索1 天前
python文件与数据格式化
开发语言·python
weixin_440730501 天前
java结构语句学习
java·开发语言·学习
JIngJaneIL1 天前
基于java+ vue医院管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
量子联盟1 天前
功能完整的PHP站点导航管理系统php程序;开源免费下载
开发语言·php
仙俊红1 天前
在 Java 中,`==` 和 `equals()` 的区别
java·开发语言·jvm
信创天地1 天前
信创国产化数据库的厂商有哪些?分别用在哪个领域?
数据库·python·网络安全·系统架构·系统安全·运维开发
JIngJaneIL1 天前
基于java + vue校园跑腿便利平台系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
不哦罗密经1 天前
python相关
服务器·前端·python