码迷,mamicode.com
首页 > 其他好文 > 详细

遍历各个像素点并对其进行修改

时间:2018-07-21 21:32:56      阅读:371      评论:0      收藏:0      [点我收藏+]

标签:range   修改   write   遍历   route   ack   else   users   read   

#Author C

import os
import cv2
list = []
for filename in os.listdir(r‘C:\Users\Uaena\Desktop\crack‘):
route = r‘C:\Users\Uaena\Desktop\crack\\‘ + filename
list.append(route)
print(list)


for n in range(len(list)):

img1=cv2.imread(list[n])
sq = img1.shape
l=sq[0]
width=sq[1]
for i in range(l):
for j in range(width):
if img1[i,j][0] == 0 and img1[i,j][1] ==0 and img1[i,j][2] == 0:
img1[i, j] = [0,0,0]
else:
# img1[i,j]=[0,0,0]
img1[i, j]=[255,255,255]

cv2.imwrite(r"C:\Users\Uaena\Desktop\bd\%d.jpg"%(n),img1)

遍历各个像素点并对其进行修改

标签:range   修改   write   遍历   route   ack   else   users   read   

原文地址:https://www.cnblogs.com/mrc-369-com/p/9347914.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!