首页 > 编程语言 > 详细

TypeError系列之:TypeError: only size-1 arrays can be converted to Python scalars&Numpy读取图片遍历像素值

时间:2020-09-01 14:14:17      阅读:240      评论:0      收藏:0      [点我收藏+]

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

维数

 

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)

TypeError系列之:TypeError: only size-1 arrays can be converted to Python scalars&Numpy读取图片遍历像素值

原文:https://www.cnblogs.com/2008nmj/p/13595629.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!