create_doc.py
Go to the documentation of this file.
1 import os
2 import math
3 from PIL import Image
4 
5 from rose_v2_repo import runMe
6 
7 skip_choice = True
8 types = ['/2_Hough.png', '/4_Contour.png', '/7b_DBSCAN_th1.png', '/8b_rooms_th1.png', '/8b_rooms_th1_on_map.png', '/8b_rooms_th1_on_map_prediction.png', '/8b_rooms_th1_on_map_th1.png', '/Extended_Lines/7a_extended_lines_th1.png']
9 names = ['Hough_collage.png', 'Contour_collage.png', 'dbscan_collage.png', 'rooms_collage.png', 'segmentation_collage.png', 'segmentation_prediction_collage.png', 'segmentation_lines_collage.png', 'extended_lines_collage.png']
10 
11 
12 def create_collage(cols, rows, listofimages, output_path, name):
13  img = listofimages[0]
14  width = cols * img.width + 10 * cols
15  height = rows * img.height + 10 * rows
16  thumbnail_width = width//cols
17  thumbnail_height = height//rows
18  size = thumbnail_width, thumbnail_height
19  new_im = Image.new('RGB', (width, height), 'white')
20  ims = []
21  for im in listofimages:
22  im.thumbnail(size)
23  ims.append(im)
24  i = 0
25  x = 0
26  y = 0
27  for col in range(cols):
28  for row in range(rows):
29  new_im.paste(ims[i], (x, y))
30  i += 1
31  y += thumbnail_height + 10
32  x += thumbnail_width + 10
33  y = 0
34 
35  new_im.save(output_path + name)
36 
37 
39  while True:
40  print('What kind of image do you want to use?\n1 Hough\n2 contour\n3 dbscan\n4 rooms\n5 '
41  'rooms on map\n6 rooms prediction\n7 rooms and lines\n8 extended lines\n')
42  try:
43  val = int(input('insert the number of action selected\n'))
44  if val == 1:
45  return '/2_Hough.png', 'Hough_collage.png'
46  elif val == 2:
47  return '/4_Contour.png', 'Contour_collage.png'
48  elif val == 3:
49  return '/7b_DBSCAN_th1.png', 'dbscan_collage.png'
50  elif val == 4:
51  return '/8b_rooms_th1.png', 'rooms_collage.png'
52  elif val == 5:
53  return '/8b_rooms_th1_on_map.png', 'segmentation_collage.png'
54  elif val == 6:
55  return '/8b_rooms_th1_on_map_prediction.png', 'segmentation_prediction_collage.png'
56  elif val == 7:
57  return '/8b_rooms_th1_on_map_th1.png', 'segmentation_lines_collage.png'
58  elif val == 8:
59  return '/Extended_Lines/7a_extended_lines_th1.png', 'extended_lines_collage.png'
60  except ValueError:
61  print('invalid input')
62 
63 
64 def main():
65  input_folder = '../data/OUTPUT/'
66  output_folder = '../data/OUTPUT/collage/'
67  if not os.path.exists(output_folder):
68  os.mkdir(output_folder)
69  sim = runMe.check_int(input_folder)
70  input_folder = input_folder + sim + '/'
71  output_folder = output_folder + sim + '/'
72  if not os.path.exists(output_folder):
73  os.mkdir(output_folder)
74  list_image = []
75  list_run = os.listdir(input_folder)
76  count = len(list_run)
77  cols = int(math.sqrt(count))
78  rows = int(math.sqrt(count))
79  print(cols, rows, count)
80  map = list_run[0]
81  map_name = '/' + os.listdir(input_folder + map)[0]
82  list_run.sort()
83  if skip_choice is True:
84  for i in range(0, 8):
85  type = types[i]
86  name = names[i]
87  for run in list_run:
88  image = Image.open(input_folder + run + map_name + type)
89  list_image.append(image)
90  create_collage(cols, rows, list_image, output_folder, name)
91  else:
92  type, name = ask_collage_image()
93  for run in list_run:
94  image = Image.open(input_folder + run + map_name + type)
95  list_image.append(image)
96  create_collage(cols, rows, list_image, output_folder, name)
97 
98 
99 if __name__ == '__main__':
100  main()
create_doc.main
def main()
Definition: create_doc.py:64
create_doc.create_collage
def create_collage(cols, rows, listofimages, output_path, name)
Definition: create_doc.py:12
create_doc.ask_collage_image
def ask_collage_image()
Definition: create_doc.py:38
voronoi.input
input
Definition: voronoi.py:797


rose2
Author(s): Gabriele Somaschini, Matteo Luperto
autogenerated on Wed Jun 28 2023 02:21:53