Batch converting rover images for photogrammetry#
This notebook will introduce advanced image filtering and parallel processing.
Many of it’s functions are designed to prepare rover images for photogrammetry processing.
from pathlib import Path
from marsimage.batch_processing import process_images
from marsimage.download import download_msl
Filtering images#
Many rover images are unsuited for photogrammetry (for example sky surveys, autofocus images, instrument inspections, etc..).
Therefore we need to filter them out before converting the images. Batch Processing implements several filter functions that are designed to remove these images. They are still a work in progress and may break for some parts of the mission. If they should break, you can implement your own filters and pass them to the batch processing function.
download_dir = './temp/MontMercouHazcam/'
# this will download all MSL Hazcam images from sol 3074 to 3076
download_msl('hazcam', sol_start=3074, sol_end=3076, output_dir=download_dir);
Downloading images from Sol 3074 to Sol 3076 for HAZCAM.
Batch Converting the images#
With the process_images() function we can now convert the PDS products to TIFF files and automatically apply masks in the alpha-channel.
It is possible to specify a very flexible grouping pattern. You can specify any folder pattern from the following keywords:
sol, cam_id, site, drive, rmc, site_drive
any attribute of the MarsImage object, like mission_id, width, target, etc…
Examples:
'sol/cam_id/site/drive'would save to something like this:3048/MAST_LEFT/Site_87/Drive_420/'mission_id/instrument_name'would save to something like this:'MSL/MAST_CAMERA_LEFT/'
# get all the Hazcam images from the download directory
images = list(Path('./temp/MontMercouHazcam/').rglob('*.IMG'))
output_dir = './temp/MontMercouHazcam/converted/'
# process the images in parrallel, group them by camera id and apply the mask
process_images(images, output_dir, group='cam_id', apply_mask=True)