vista.algorithms.background_removal.static_median_background_removal.static_median_background_removal¶
- vista.algorithms.background_removal.static_median_background_removal.static_median_background_removal(background_images, target_images, callback=None)[source]¶
Subtract a median background image, computed from a fixed set of frames, from each target frame.
The median is computed pixelwise over
background_images(typically a quiescent period without transient events). The same median image is subtracted from every frame intarget_images.- Parameters:
background_images (numpy.ndarray) – 3D array of shape (num_background_frames, height, width) used to compute the median background.
target_images (numpy.ndarray) – 3D array of shape (num_target_frames, height, width) to which the background removal is applied. Must share height and width with
background_images.callback (callable, optional) – Called after each target frame with (frame_processed, total_frames). Should return False to cancel processing.
- Returns:
(background, foreground) arrays with the shape and dtype of
target_images. The background array contains the same median image broadcast to each target frame.- Return type:
tuple of (numpy.ndarray, numpy.ndarray)
- Raises:
InterruptedError – If the callback returns False (user cancellation).
ValueError – If the height/width of
background_imagesandtarget_imagesdo not match, or ifbackground_imagesis empty.