Batch processing module#
Batch processing of MarsImages for photogrammetry.
These functions are work in progress and subject to change in a future release!
- marsimage.batch_processing.filter_photogrammetry(img)[source]#
Determine if an image should be used for photogrammetry based on its metadata.
- Parameters:
img (MarsImage) β The image to be filtered.
- Returns:
True if the image should be used for photogrammetry, False otherwise.
- Return type:
- marsimage.batch_processing.filter_ecam_photogrammetry(img)[source]#
Filter ECAM images that are not suitable for photogrammetry.
- marsimage.batch_processing.filter_mcam_photogrammetry(img)[source]#
Filter Mastcam images that are not suitable for photogrammetry.
- marsimage.batch_processing.filter_mahli_photogrammetry(img)[source]#
Filter MAHLI images that are not suitable for photogrammetry.
- class marsimage.batch_processing.KeyMapper(img: MarsImage)[source]#
Internal Key mapper for the get_group_folder function.
- property site#
Site_###.
- property drive#
Drive_###.
- property site_drive#
Site_###_###.
- property rmc#
Site_###_###.
- marsimage.batch_processing.get_group_folder(img: MarsImage, group_method: list | str | None)[source]#
Generate a folder path for a MarsImage according to the grouping method.
- Parameters:
img (MarsImage)
group_method (list | str | None) β
This can be either a list of group keywords, or a partial folder path as a string with keywords separated by β/β. If None, the function will return ββ and the images will not be grouped.
Possible keywords: - sol, cam_id, site, drive, rmc, site_drive - any attribute of the MarsImage object, like mission_id, width, target, etcβ¦
- Returns:
str
- Return type:
The grouping path for the image
Examples
>>> get_group_folder(img, 'sol/cam_id/site/drive') '3048/MAST_LEFT/Site_87/Drive_420/' >>> get_group_folder(img, 'mission_id\\instrument_name') 'MSL/MAST_CAMERA_LEFT/'
- marsimage.batch_processing.process_image(image_path, output_dir=None, uncrop=True, image_filter=<function filter_photogrammetry>, group='cam_id', apply_mask=True)[source]#
Process a single image file.
- Parameters:
image_path (Path) β The path to the image file to be processed.
output_dir (Path, optional) β The directory to save the converted images. If None, the converted images will be saved in a subdirectory of the original images.
image_filter (callable, optional) β A function to filter that returns True if the image should be processed. If the image_filter argument is set to None, all images will be processed. See filter_photogrammetry for an example.
group (str, optional) β
The method to group the converted images. This can be either a list of group keywords, or a partial folder path as a string with keywords separated by or /.
- Possible keywords:
sol, cam_id, site, drive, rmc, site_drive
any attribute of the MarsImage object, like mission_id, width, target, etcβ¦
See get_group_folder for more information.
apply_mask (bool, optional) β If True, apply the mask to the converted images as an alpha channel.
num_threads (int, optional) β The number of threads to use for parallel processing
- marsimage.batch_processing.process_images(image_list, output_dir=None, uncrop=True, group='cam_id', apply_mask=True, image_filter=<function filter_photogrammetry>, num_threads=None)[source]#
Process a list of images in parallel.
- Parameters:
image_list (list of Path) β A list of paths to the image files to be processed.
output_dir (Path, optional) β The directory to save the converted images. If None, the converted images will be saved in a subdirectory of the original images.
group (str, optional) β
The method to group the converted images. This can be either a list of group keywords, or a partial folder path as a string with keywords separated by or /.
- Possible keywords:
sol, cam_id, site, drive, rmc, site_drive
any attribute of the MarsImage object, like mission_id, width, target, etcβ¦
image_filter (callable, optional) β A function to filter that returns True if the image should be processed. See filter_photogrammetry for an example.
apply_mask (bool, optional) β If True, apply the mask to the converted images as an alpha channel.
num_threads (int, optional) β The number of threads to use for parallel processing. By default, the number of threads is set to the number of CPU cores.