(output_dir)
| 1067 | |
| 1068 | |
| 1069 | def hist(output_dir): |
| 1070 | def process_image(f, filename): |
| 1071 | image = cv2.imread(f, cv2.IMREAD_GRAYSCALE) |
| 1072 | if image is not None: |
| 1073 | plt.hist(image.ravel(), bins=256, range=[0, 256]) |
| 1074 | plt.title("Histogram") |
| 1075 | plt.savefig(os.path.join(hist_dir, f"{filename}_histogram.png")) |
| 1076 | plt.close() |
| 1077 | prGreen(f"[HIST] Saved histogram for {filename}") |
| 1078 | |
| 1079 | hist_dir = os.path.join(results_folder, "hist") |
| 1080 | os.makedirs(hist_dir, exist_ok=True) |
| 1081 | |
| 1082 | for ext in ["png", "jpg"]: |
| 1083 | dir_path = os.path.join(output_dir, ext) |
| 1084 | if os.path.isdir(dir_path): |
| 1085 | files = [f for f in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, f))] |
| 1086 | with ThreadPoolExecutor(max_workers=os.cpu_count() - 1) as executor: |
| 1087 | for filename in tqdm(files, desc=f"Histogram {ext.upper()} test: "): |
| 1088 | f = os.path.join(dir_path, filename) |
| 1089 | executor.submit(process_image, f, filename) |
| 1090 | prGreen("HIST TEST DONE") |
| 1091 | |
| 1092 | |
| 1093 | def jpeg(output_dir): |
no test coverage detected