spymicmac.preprocessing#

spymicmac.preprocessing is a collection of tools for preprocessing images

KH-9 Hexagon mapping camera#

spymicmac.preprocessing.preprocess_kh9_mc(steps='all', skip='none', nproc=1, add_sfs=False, cam_csv='camera_defs.csv', tar_ext='.tgz', is_reversed=False, overlap=2000, block_size=2000, blend=False, scale=70, clip_limit=0.005, res_low=400, res_high=1200, camera_model='RadialExtended', ori='Relative', init_cal='Init', lib_foc=False, lib_pp=False, lib_cd=False, add_params=False)[source]#

Run pre-processing steps for KH-9 Hexagon Mapping Camera images. By default, runs all steps (equivalent to steps=’all’):

  • extract: extracts images from tar files (skips if no tar files are found)

  • join: joins scanned image halves

  • reseau: finds reseau marker locations in the joined image

  • erase: erases reseau markers from image

  • filter: use a 1-sigma gaussian filter to smooth the images before resampling

  • resample: resamples images to common size using the reseau marker locations

  • balance: use contrast-limited adaptive histogram equalization (clahe) to improve contrast in the image

  • tapioca: calls mm3d Tapioca MulScale to find tie points

  • tapas: calls mm3d Tapas to calibrate camera model, find relative image orientation

  • aperi: calls mm3d AperiCloud to create point cloud using calibrated camera model

To run steps individually, pass them to the steps argument as a list. For example, to only run the ‘reseau’ and ‘erase’ steps:

preprocess_kh9_mc(steps=[‘reseau’, ‘erase’])

Parameters:
  • steps (str | list) – The pre-processing steps to run

  • skip (str | list) – The pre-processing steps to skip

  • nproc (int | str) – The number of sub-processes to use - either an integer value, or ‘max’. If ‘max’, uses mp.cpu_count() to determine the total number of processors available.

  • add_sfs (bool) – use SFS to help find tie points in low-contrast images

  • cam_csv (str) – Name of the CSV file containing camera information

  • tar_ext (str) – Extension for tar files

  • is_reversed (bool) – Order of image parts is reversed (a is the right side of the image)

  • overlap (int) – The amount of overlap between image parts to use to search for matches

  • block_size (int) – The number of rows each search sub-block should cover

  • blend (bool) – Blend across image halves to prevent a sharp line at edge

  • scale (int) – The scale of the resampled images, in pixels per mm

  • clip_limit (float) – Clipping limit, for contrast-limited adaptive histogram equalization

  • res_low (int) – The size of the largest image axis, in pixels, for low-resolution matching with Tapioca

  • res_high (int) – The size of the largest image axis, in pixels, for high-resolution matching with Tapioca

  • camera_model (str) – The camera calibration model to use for Tapas

  • ori (str) – The output Ori directory to create using Tapas

  • init_cal (str) – The initial calibration Ori to use for Tapas

  • lib_foc (bool) – Use LibFoc=1 for mm3d Tapas

  • lib_pp (bool) – Use LibPP=1 for mm3d Tapas

  • lib_cd (bool) – Use LibCD=1 for mm3d Tapas

  • add_params (bool) – Add decentric and affine parameters to the camera model

Return type:

None

spymicmac.preprocessing.initialize_kh9_mc(add_sfs=False, cam_csv='camera_defs.csv', overwrite=False)[source]#

Initialize the following files needed for processing KH-9 MC images, if they do not already exist:

  • MicMac-LocalChantierDescripteur.xml

  • Ori-Init/AutoCal_Foc-304800_KH9MC.xml

  • Ori-InterneScan/MeasuresCamera.xml

If multiple “cameras” (i.e., images acquired from different missions) are being used, these should be defined in a cam_csv file, as generated by micmac.generate_multicam_csv().

Parameters:
  • add_sfs (bool) – use SFS to help find tie points in low-contrast images

  • cam_csv (str) – the name of the CSV file containing camera information

  • overwrite (bool) – overwrite existing files

Return type:

None

panoramic cameras#

spymicmac.preprocessing.preprocess_pan(flavor, steps='all', skip='none', tar_ext='.tgz', is_reversed=False, overlap=2000, block_size=2000, blend=False, marker_size=31, factor=None, clip_limit=0.005)[source]#

Run pre-processing steps for declassified panoramic images (e.g., KH-4 and KH-9 Panoramic Camera). By default, runs all steps (equivalent to steps=’all’):

  • extract: extracts images from tar files (skips if no tar files are found)

  • join: joins scanned image halves

  • filter: use a 1-sigma gaussian filter to smooth the images before cropping

  • crop: rotate and crop images to remove image frame

  • balance: use contrast-limited adaptive histogram equalization (clahe) to improve contrast in the image

To run steps individually, pass them to the steps argument as a list. For example, to only run the ‘join’ and ‘crop’ steps:

preprocess_pan(steps=[‘join’, ‘crop’])

Parameters:
  • flavor (str) – The camera type (KH4 or KH9)

  • steps (str | list) – The pre-processing steps to run

  • skip (str | list) – The pre-processing steps to skip

  • tar_ext (str) – Extension for tar files

  • is_reversed (bool) – Order of image parts is reversed (a is the right side of the image)

  • overlap (int) – The amount of overlap between image parts to use to search for matches

  • block_size (int) – The number of rows each search sub-block should cover

  • blend (bool) – Blend across image halves to prevent a sharp line at edge

  • marker_size (int) – The size of the wagon wheel or rail markers to identify in the image

  • factor (int | None) – The number by which to divide the image width and height to scale the image (default: do not scale)

  • clip_limit (float) – Clipping limit, for contrast-limited adaptive histogram equalization

Return type:

None