You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
exercise_2/txl/huidu_shuai.py

46 lines
1.3 KiB

import PIL.Image
import numpy
import os
import shutil
def sum_right(path):
img = PIL.Image.open(path)
array = numpy.array(img)
num = array.sum(axis=0)
print(type(num))
res_left = 0
res_right = 0
for i in range(256,512):
res_right += num[i]
print(res_right)
if __name__ == '__main__':
dir2 = r"C:\Users\xinluo\PycharmProjects\pythonProject\Camera Roll"
dir1 = r"C:\Users\xinluo\PycharmProjects\pythonProject\Saved Pictures"
names = os.listdir(dir1)
n = len(names)
print("文件数量",n)
res = 0
average_5 = 25565356
average_25 = 26409377
average_5_right = 10006019
average_tmp = (average_25+average_5)//2
count = 0
show(os.path.join(dir1, "uni4F6C.png"))
for i in range(n):
#取图片
img = PIL.Image.open(os.path.join(dir1,names[i]))
file = os.path.join(dir1,names[i])
rmfile = os.path.join(dir2,names[i])
array = numpy.array(img)
num = array.sum(axis=0)
res_right = 0
for i in range(256, 512):
res_right += num[i]
average_5_right += res_right/n
if (res_right > average_5_right).all():
shutil.copyfile(file, rmfile)
os.remove(file)
count += 1
print(average_5_right)
print(count)