autoemxsp.core.particle_segmentation_models.Rettenberger2024 module

Created on Thu Oct 9 09:34:39 2025

Particle segmentation model from:

Rettenberger, L., Szymanski, N.J., Zeng, Y. et al. Uncertainty-aware particle segmentation for electron microscopy at varied length scales. npj Comput Mater 10, 124 (2024). https://doi.org/10.1038/s41524-024-01302-w

To use this model for particle segmentation, clone the repo from https://github.com/lrettenberger/Uncertainty-Aware-Particle-Segmentation-for-SEM to the same directory as this module, and rename it Rettenberg2024_model_data

@author: Andrea

autoemxsp.core.particle_segmentation_models.Rettenberger2024.segment_particles(frame_image: ndarray, powder_meas_config: PowderMeasurementConfig = None, save_image: bool = False, EM: EM_controller = None) ndarray[source]

Segments particles in the given frame image using a Mask R-CNN ONNX model, then returns an 8-bit index map image where each detected particle is assigned a unique brightness value based on its index.

Parameters:
  • frame_image (ndarray) – A grayscale (or RGB) input image of the current frame containing particles.

  • save_image (bool) – Optionally save the 8-bit index map through EM_controller.

  • EM (EM_controller object) – Used to optionally save the 8-bit index map image.

Returns:

par_mask – An 8-bit index image where: - Background pixels are 0. - Each particle (up to 255 particles) receives an index 1..255 and all of

its pixels are set to that index value. If >255 particles are found, the extras are set to 255.

Return type:

ndarray (uint8)

Note

  • All configuration is hardcoded inside this function.

  • The ONNX model path is resolved relative to this file.