-
Notifications
You must be signed in to change notification settings - Fork 0
/
invert.py
32 lines (27 loc) · 1.04 KB
/
invert.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
import random
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import os
from pandas import DataFrame
import pandas as pd
from PIL import Image
# loads images from the folder. Flips them and saves them in the same folder
def load_flip_images(load_path, save_path):
i = 0
for filename in os.listdir(load_path):
i = i+1
p = os.path.join(load_path, filename)
if p == load_path + '/.DS_Store':
continue
img = Image.open(p)
flipped_image = img.transpose(Image.FLIP_LEFT_RIGHT)
img.save(save_path + '/Image_'+str(i)+'.png')
flipped_image.save(save_path + '/Image_'+str(i+10000)+'.png')
if __name__ == '__main__':
base_path = '/Users/swarajdalmia/Desktop/NeuroMorphicComputing/Code'
load_path = base_path + '/Data/circuitImages/usefulCircuits/withObstacles_withoutNoise'
save_path = base_path + '/Data/circuitImages/usefulCircuits/biggerDataset'
load_flip_images(load_path, save_path)
# plt.imshow(images[0])
# plt.show()