wormpose.dataset.image_processing.simple_frame_preprocessing

Simple BaseFramePreprocesing implementation

class wormpose.dataset.image_processing.simple_frame_preprocessing.SimpleFramePreprocessing(is_foreground_lighter_than_background: bool, foreground_dilate_struct_element=array([[0, 0, 1, 0, 0],        [1, 1, 1, 1, 1],        [1, 1, 1, 1, 1],        [1, 1, 1, 1, 1],        [0, 0, 1, 0, 0]], dtype=uint8), foreground_close_struct_element=array([[0, 1, 0],        [1, 1, 1],        [0, 1, 0]], dtype=uint8), threshold_fn: Callable = <wormpose.dataset.image_processing.image_utils.OtsuThreshold object>)[source]
process(frame: numpy.ndarray, background_threshold: Optional[int] = None) Tuple[numpy.ndarray, int][source]

Segment the worm object of interest in the image: returns a mask image of the same shape as frame, where the pixels belong to the worm object of interest are 1, and all the others are 0 Also calculates the average value of the background pixels.

Parameters

frame – image to process

Returns

Segmentation mask image , background color