我的github
posts - 3243,  comments - 42,  views - 158万

import cv2

labels_path = "test/labels/"
labels2_path = "test/labels2/"

for image in os.listdir(labels_path):
#print(image)
index, _ = os.path.splitext(image)
print(index)
image_file = os.path.join(labels_path, image)
img = cv2.imread(image_file).astype(np.float32)
#img2 = np.array(img);
#print(img2)
save_img = np.zeros((256, 256), dtype=np.uint16)
for i in range(256):
for j in range(256):
#save_img[i][j] = int(img[i][j] / 100.0) #img2
print(img[i][j])
cv2.imwrite(os.path.join(labels_path, index+".png"), save_img)

 

cv2.imread()读取图片后已多维数组的形式保存图片信息,前两维表示图片的像素坐标,最后一维表示图片的通道索引,具体图像的通道数由图片的格式来决定:https://blog.csdn.net/lccrun/article/details/95594268

cv2.imwrite():https://www.cnblogs.com/shizhengwen/p/8719062.html

 

 

TypeError系列之:TypeError: only size-1 arrays can be converted to Python scalars

https://blog.csdn.net/qq_41368074/article/details/105728204?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight

维数

 

三大用于数据科学的顶级Python库:https://www.sohu.com/a/254597312_100159565 NumPy、Pandas、MatPlot

 

cv2读取的mat如何转为numpy的数组呢?opencv和Numpy如何互相数据转换:数据结构上有何相同和不同之处 https://www.cnblogs.com/ansang/p/8137114.html

 

如何进行像素操作:读取和赋值 x,y=pixel

https://www.matools.com/blog/190496442

https://baijiahao.baidu.com/s?id=1645986288459279361&wfr=spider&for=pc

posted on   XiaoNiuFeiTian  阅读(1481)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2018-09-01 Dennis Gabor与全息摄影
2018-09-01 Gabor filter与Gabor transform
2018-09-01 图像生成器:让电脑学习生成数字图像
2018-09-01 Haar-like feature和Haar wavelet
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示