2 from random
import randint
6 if __name__ ==
'__main__':
7 input_path =
'./../data/INPUT/gt_colored//'
8 for map
in os.listdir(input_path):
9 output_path = input_path + map
10 tmp = cv2.imread(input_path + map)
12 img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
13 th, img = cv2.threshold(img, 230, 255, cv2.THRESH_BINARY)
14 img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
16 for y
in range(img.shape[0] - 1):
17 for x
in range(img.shape[1] - 1):
18 pixel = list(img[(y, x)])
19 if pixel == [255, 255, 255]:
20 random_color = (randint(1, 254), randint(1, 254), randint(1, 254))
23 if random_color
in colors:
24 random_color = (randint(1, 254), randint(1, 254), randint(1, 254))
27 cv2.floodFill(img,
None, (x, y), random_color, flags=8)
28 cv2.imwrite(output_path, img)