-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflip_tess.py
48 lines (35 loc) · 1.33 KB
/
flip_tess.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 sys
from PIL import Image, ImageOps
import argparse
def parse_args():
parser = argparse.ArgumentParser(description='Reflective Padded Image')
parser.add_argument('-img_in',dest='img_in',help='grayscale image to read in', type=str)
parser.add_argument('-img_out',dest='img_out',help='colorized image to save off', type=str)
args = parser.parse_args()
return args
if __name__ == '__main__':
args = parse_args()
image = Image.open(args.img_in).convert('LA')
width, height = image.size
total_width = width * 3
max_height = height * 3
#Creating the image
new_im = Image.new('RGB', (total_width, max_height))
#Pasting original image
new_im.paste(image, (width, height))
#Pasting vert flips
vert_flip = ImageOps.flip(image)
new_im.paste(vert_flip, (width, 0))
new_im.paste(vert_flip, (width, 2*height))
#Pasting horiz flip
hor_flip = ImageOps.mirror(image)
new_im.paste(hor_flip, (0, height))
new_im.paste(hor_flip, (2*width, height))
#pasting double flip
doub_flip = ImageOps.mirror(vert_flip)
new_im.paste(doub_flip, (0,0))
new_im.paste(doub_flip, (2*width, 0))
new_im.paste(doub_flip, (0, 2*height))
new_im.paste(doub_flip, (2*width, 2*height))
image.save(args.img_out + 'bw.png')
new_im.save(args.img_out + 'tess.png')