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

建立彩色的随机数图像。

相关推荐
MarcoPage33 分钟前
Python 字典推导式入门:一行构建键值对映射
java·linux·python
独隅4 小时前
在 Lua 中,你可以使用 `os.date()` 函数轻松地将时间戳转换为格式化的时间字符串
开发语言·lua
思麟呀5 小时前
Linux的基础IO流
linux·运维·服务器·开发语言·c++
星释5 小时前
Rust 练习册 :Pythagorean Triplet与数学算法
开发语言·算法·rust
星释5 小时前
Rust 练习册 :Nth Prime与素数算法
开发语言·算法·rust
lkbhua莱克瓦246 小时前
Java基础——集合进阶3
java·开发语言·笔记
ζั͡山 ั͡有扶苏 ั͡✾6 小时前
从零搭建 Data-Juicer:一站式大模型数据预处理与可视化平台完整教程
python·data-juicer
多喝开水少熬夜6 小时前
Trie树相关算法题java实现
java·开发语言·算法
QT 小鲜肉6 小时前
【QT/C++】Qt定时器QTimer类的实现方法详解(超详细)
开发语言·数据库·c++·笔记·qt·学习
SkylerHu6 小时前
tornado+gunicorn部署设置max_body_size
python·tornado·gunicorn