遍历各个像素点并对其进行修改
Posted mrc-369-com
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了遍历各个像素点并对其进行修改相关的知识,希望对你有一定的参考价值。
#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)
以上是关于遍历各个像素点并对其进行修改的主要内容,如果未能解决你的问题,请参考以下文章