This page gives an overview of the segmentation model ImageDataExtractor used to detect particles, as well as how it is used as a standalone segmentation model outside of a data extraction context.


ImageDataExtractor uses a segmentation method called BPartIS, which is a Bayesian deep neural network trained to segment particles in electron microscopy images. By default, this is run in Bayesian mode, which affords more accurate segmentations at the cost of some speed.


>>> import cv2
>>> from imagedataextractor.segment import ParticleSegmenter

>>> segmenter = ParticleSegmenter(bayesian=True, tu=0.0125, n_samples=50, device='cpu')

>>> image = cv2.imread('<path/to/image>')  # PIL can also be used

>>> segmentation, uncertainty, _ = segmenter.segment(image)