cars.extractroi

cars-extractroi: helper to extract region of interest from image product

Module Contents

Functions

is_bbx_in_image(bbx, image_dataset)

Checks if the bounding box is within the image.

get_slices_from_bbx(image_dataset, bbx)

get slices from bounding box

process_image_file(bbx, input_image_path, ...)

Processes an image file by extracting a region based on the given geometry.

get_human_readable_bbox(image_dataset)

Get the human-readable bounding box from an image dataset.

validate_bounding_box(bbx, image_dataset)

Validate the bounding box coordinates.

create_geom_file(image_dataset, geom_filename)

Create and save a .geom file from a rasterio dataset

main()

Main cars-extractroi entrypoint

cars.extractroi.is_bbx_in_image(bbx, image_dataset)[source]

Checks if the bounding box is within the image.

Parameters:

bbx (array): The bounding box of the image. image_dataset (rio.DatasetReader): Opened image dataset.

cars.extractroi.get_slices_from_bbx(image_dataset, bbx)[source]

get slices from bounding box

Parameters:

image_dataset (rio.DatasetReader): Opened image dataset. bbx (array): The bounding box of the image.

Returns:

tuple: The slices from the bounding box.

cars.extractroi.process_image_file(bbx, input_image_path, output_image_path, geom_file_path)[source]

Processes an image file by extracting a region based on the given geometry.

Parameters:

region_geometry (dict): GeoJSON-like dictionary defining the region. input_image_path (str): Path to the input image file. output_image_path (str): Path to save the output image. geom_file_path (str): Path to save the .geom file.

cars.extractroi.get_human_readable_bbox(image_dataset)[source]

Get the human-readable bounding box from an image dataset.

Parameters:

image_dataset (rio.DatasetReader): Opened image dataset.

Returns:

tuple: The human-readable bounding box in the format (min_x, max_x, min_y, max_y).

cars.extractroi.validate_bounding_box(bbx, image_dataset)[source]

Validate the bounding box coordinates.

Parameters:

bbx (array): The bounding box of the image. image_dataset (rio.DatasetReader): Opened image dataset.

cars.extractroi.create_geom_file(image_dataset, geom_filename)[source]

Create and save a .geom file from a rasterio dataset

Parameters:

image_dataset (rio.DatasetReader): Opened image dataset. geom_filename (str): Path to save the .geom file.

cars.extractroi.main()[source]

Main cars-extractroi entrypoint