From 3ebfcd410fbb0574ad9f7fcc2e78f86774035275 Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Mon, 15 Sep 2025 18:39:48 +0200 Subject: [PATCH] =?UTF-8?q?template=20f=C3=BCr=20gelben=20hintergrund?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/ex/image_cleaner.py | 14 +++++++++++++- scripts/ex/light_config.json | 12 ++++++++++++ scripts/ex/smooth_yellow_config.json | 12 ++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 scripts/ex/light_config.json create mode 100644 scripts/ex/smooth_yellow_config.json diff --git a/scripts/ex/image_cleaner.py b/scripts/ex/image_cleaner.py index 33a6c4d..edc9708 100644 --- a/scripts/ex/image_cleaner.py +++ b/scripts/ex/image_cleaner.py @@ -10,6 +10,7 @@ import numpy as np from PIL import Image, ImageEnhance import os import argparse +import json from pathlib import Path @@ -289,10 +290,21 @@ if __name__ == "__main__": choices=['denoise', 'contrast', 'background', 'sharpen'], default=['denoise', 'contrast', 'background', 'sharpen'], help="Processing steps to apply") + parser.add_argument("--config", help="JSON config file with custom parameters") args = parser.parse_args() - cleaner = NewspaperImageCleaner() + # Load config if provided + config = None + if args.config and os.path.exists(args.config): + with open(args.config, 'r') as f: + config = json.load(f) + # Convert list back to tuple if needed + if config and 'clahe_grid_size' in config: + config['clahe_grid_size'] = tuple(config['clahe_grid_size']) + print(f"Loaded config from: {args.config}") + + cleaner = NewspaperImageCleaner(config) if args.directory: output_dir = args.output or "cleaned_images" diff --git a/scripts/ex/light_config.json b/scripts/ex/light_config.json new file mode 100644 index 0000000..34a8dda --- /dev/null +++ b/scripts/ex/light_config.json @@ -0,0 +1,12 @@ +{ + "bilateral_d": 3, + "bilateral_sigma_color": 50, + "bilateral_sigma_space": 30, + "denoise_h": 3, + "morph_kernel_size": 1, + "clahe_clip_limit": 1.2, + "gamma": 1.05, + "unsharp_amount": 1.1, + "unsharp_radius": 0.8, + "unsharp_threshold": 0 +} \ No newline at end of file diff --git a/scripts/ex/smooth_yellow_config.json b/scripts/ex/smooth_yellow_config.json new file mode 100644 index 0000000..ba6f829 --- /dev/null +++ b/scripts/ex/smooth_yellow_config.json @@ -0,0 +1,12 @@ +{ + "bilateral_d": 7, + "bilateral_sigma_color": 100, + "bilateral_sigma_space": 40, + "denoise_h": 4, + "morph_kernel_size": 1, + "clahe_clip_limit": 1.0, + "gamma": 1.0, + "unsharp_amount": 1.2, + "unsharp_radius": 0.8, + "unsharp_threshold": 2 +} \ No newline at end of file