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
维数
三大用于数据科学的顶级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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.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