BlurCV2#
- class deeptrack.optical.math.BlurCV2(filter_function: Callable | str, mode: str | Callable[[...], str] = 'reflect', **kwargs: Any)#
Bases:
FeatureApply a blurring filter using OpenCV (cv2).
Applies an OpenCV-based blurring or filtering operation to an input image. The provided filter_function must be compatible with OpenCV and accept the input image via the src argument (e.g., cv2.GaussianBlur, cv2.bilateralFilter).
Parameters#
- filter_functionCallable or str
OpenCV-compatible filtering function. If a string is provided, it is resolved as an attribute of cv2.
- modestr, default=”reflect”
Border handling mode. Supported values are: {‘reflect’, ‘wrap’, ‘constant’, ‘mirror’, ‘nearest’}. These are internally mapped to OpenCV border types.
- **kwargsAny
Additional keyword arguments passed directly to the filtering function.
Methods#
- get(image: np.ndarray, **kwargs: Any) –> array
Applies the blurring filter to the input image.
Notes#
BlurCV2 is NumPy-only and does not support PyTorch tensors.
Examples#
>>> import deeptrack as dt
Create an input image:
>>> import numpy as np >>> >>> input_image = np.random.rand(32, 32)
Define a blur feature using the Gaussian blur function:
>>> import cv2 >>> >>> blur = dt.BlurCV2( ... filter_function=cv2.GaussianBlur, ... ksize=(5, 5), ... sigmaX=1, ... mode='reflect', ... ) >>> output_image = blur(input_image) >>> print(output_image.shape) (32, 32)
Methods Summary
get(image, mode, **kwargs)Applies the blurring filter to the input image.
Methods Documentation
- get(image: ndarray, mode: str, **kwargs: Any) ndarray#
Applies the blurring filter to the input image.
This method applies the blurring filter to the input image.
Parameters#
- image: np.ndarray
The input image to blur. Must be a NumPy array.
- **kwargs: Any
Additional parameters for the blurring function.
Returns#
- np.ndarray
The blurred image.