-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch_processing.py
32 lines (27 loc) · 1.52 KB
/
batch_processing.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
from preprocessing.preprocessing import preProcessing
from crawler.crawler import init_directory
from tqdm import tqdm
import numpy as np
import json
import cv2
import os
if __name__ == "__main__":
palette_dict = json.load(open("preprocessing/palette.json", "r"))
color_set = { tuple(np.array(value).astype('uint8')) for key, value in palette_dict.items() }
palette_dict = {tuple(v) : int(k) for k, v in palette_dict.items()}
init_directory("preprocess/remove_grid/")
init_directory("preprocess/numeric/")
init_directory("preprocess/sampling/")
init_directory("preprocess/sampling_image/")
all_image = [i for i in os.listdir("images/radar/")]
for filename in tqdm(all_image):
filename_noPath = os.path.basename(filename)
filename_noPath = filename_noPath[:filename_noPath.find(".")]
image = cv2.imread("images/radar/" +filename)
# preProcessing.filter(image, color_set, "preprocess/remove_grid/{}.png".format(filename_noPath))
preProcessing.color2numeric(image, palette_dict, "preprocess/numeric/{}".format(filename_noPath))
dbzImage = np.loadtxt("preprocess/numeric/{}".format(filename_noPath), delimiter=",", dtype="int")
patches = preProcessing.split_image_block(dbzImage, 6)
preProcessing.sampling(patches, 6, "preprocess/sampling/{}".format(filename_noPath))
preProcessing.convert2image("preprocess/sampling/{}".format(filename_noPath),
"preprocess/sampling_image/{}.png".format(filename_noPath))