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.
With the process_images() function we can now convert them PDS products to TIFF files and automatically apply masks in the alpha-channel.
group='cam_id' specifies that all images will be grouped by their INSTRUMENT_ID from the label.
# 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)