-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrey_pixel.py
48 lines (30 loc) · 851 Bytes
/
grey_pixel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import argparse
import dlib
import cv2
import imutils
import csv
from PIL import Image
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", type=str, default="",
help="path to input image file")
args = vars(ap.parse_args())
images = args["image"]
for fl in os.listdir(images):
#print(fl)
if fl == ".DS_Store" or fl == "_DS_Store":
print(fl)
# print("stupid files")
else:
images2 = os.path.join(images,fl)
print(images2)
frame = cv2.imread(images2)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
fl2 = fl.split(".")[0]
# img = Image.open('res96.jpg').convert('L')
# img = Image.open(images2).convert('LA')
# img2 = Image.open(img).convert('L')
# data = list(img2.getdata())
# print(data)
cv2.imwrite( str(images) + "/" + str(fl2) + ".jpg",gray)
# img.save('greyscale.png')