diff --git a/src/handlers.py b/src/handlers.py index ccae175..f47b95e 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -76,6 +76,13 @@ def process_and_clip_landsat_images() -> None: def process_bands_for_true_color_image() -> None: + """ + Processes Landsat band images to create true color images. + + This function reads Landsat band images from a specified directory, filters them based on the file extension, + and then uses these images to create true color images. The resulting true color images are saved + in a designated output directory. + """ image_paths = [ os.path.join(settings.IMAGES_DATASET.ROI_CROPPED_DATASET_PATH, file) for file in os.listdir(settings.IMAGES_DATASET.ROI_CROPPED_DATASET_PATH) @@ -88,6 +95,14 @@ def process_bands_for_true_color_image() -> None: def process_bands_for_binary_image() -> None: + """ + Processes Landsat band images to create binary images. + + This function reads Landsat band images from a specified directory, filters them based on the file extension, + and then uses these images to create binary images. The binary images are generated based on the Normalized + Difference Snow Index (NDSI) using specific bands. The resulting binary images are saved in a designated + output directory. + """ image_paths = [ os.path.join(settings.IMAGES_DATASET.ROI_CROPPED_DATASET_PATH, file) for file in os.listdir(settings.IMAGES_DATASET.ROI_CROPPED_DATASET_PATH) diff --git a/src/image_processor.py b/src/image_processor.py index 91d54fe..260a3dd 100644 --- a/src/image_processor.py +++ b/src/image_processor.py @@ -107,6 +107,9 @@ def create_true_color_images_from_landsat_bands( and generates true color images saved as PNG files in the specified directory. Missing bands for a specific date are reported, and processing continues with the next group of images. """ + if not os.path.exists(output_directory): + os.makedirs(output_directory) + grouped_paths = group_images_by_date(image_paths) required_bands = set(settings.IMAGES_DATASET.RGB_COLOR_IMAGE_BANDS) @@ -160,6 +163,9 @@ def create_binary_images_from_landsat_bands( (NDSI) using bands B3 and B6. The binary images are saved as PNG files in the specified directory. Missing bands for a specific date are reported, and processing continues with the next group of images. """ + if not os.path.exists(output_directory): + os.makedirs(output_directory) + grouped_paths = group_images_by_date(image_paths) required_bands = set(settings.IMAGES_DATASET.BINARY_IMAGE_BANDS)