Filter¶
Auto-generated documentation for musicalgestures._filter module.
- Mgt-python / Modules / Musicalgestures / Filter
filter_frame¶
Applies a threshold filter and then a median filter (of kernel_sizexkernel_size) to an image or videoframe.
Arguments¶
motion_framenp.array(uint8) - Input motion image.filtertypestr - 'Regular' turns all values belowthresholdto 0. 'Binary' turns all values belowthresholdto 0, abovethresholdto 1. 'Blob' removes individual pixels with erosion method.thresholdfloat - A number in the range of 0 to 1. Eliminates pixel values less than given threshold.kernel_sizeint - Size of structuring element.
Returns¶
np.array(uint8)- The filtered frame.
filter_frame_ffmpeg¶
def filter_frame_ffmpeg(
filename,
cmd,
color,
blur,
filtertype,
threshold,
kernel_size,
use_median,
invert=False,
):
Builds an FFmpeg filter-complex string for frame differencing, thresholding and optional median filtering.
Arguments¶
filenamestr - Path to the input video file (used to derive frame dimensions).cmdlist - Base FFmpeg command list to which extra inputs are appended in-place.colorbool - If True, use gbrp pixel format; otherwise gray.blurstr - 'Average' applies a 10×10 box blur before differencing; 'None' skips it.filtertypestr - 'Regular' thresholds frame differences; 'Binary' binarises them; 'Blob' erodes.thresholdfloat - Pixel-value threshold in the range 0–1.kernel_sizeint - Radius for the median or erosion filter.use_medianbool - If True, apply a median filter after thresholding.invertbool, optional - If True, negate the output. Defaults to False.
Returns¶
tuple[list,str] - Updatedcmdlist and the assembled filter-complex string.