Skip to content

Commit

Permalink
🔨 Add and Update docstring and create output_directory necesary folders
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianrubioa committed Jan 18, 2024
1 parent 20550c4 commit ebd2446
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/image_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ebd2446

Please sign in to comment.