BilateralBlur#
- class deeptrack.optical.math.BilateralBlur(d: int | Callable[[...], int] = 3, sigma_color: float | Callable[[...], float] = 50, sigma_space: float | Callable[[...], float] = 50, **kwargs: Any)#
Bases:
BlurCV2Apply bilateral filtering using OpenCV (cv2.bilateralFilter).
Bilateral filtering smooths homogeneous regions while preserving edges by combining spatial and intensity-based weighting.
Parameters#
- d: int
Diameter of the pixel neighborhood. If set to a non-positive value, it is computed automatically from sigma_space.
- sigma_color: float
Standard deviation in the intensity (color) space. Larger values result in stronger mixing of pixels with different intensities.
- sigma_space: float
Standard deviation in the spatial domain. Larger values allow influence from more distant pixels.
- **kwargs: Any
Additional keyword arguments passed to cv2.bilateralFilter.
Notes#
This feature supports only NumPy arrays.
PyTorch tensors are not supported.
Parameter names are mapped to OpenCV conventions: sigma_color → sigmaColor, sigma_space → sigmaSpace.
Examples#
>>> import deeptrack as dt
Create an input image:
>>> import numpy as np >>> >>> input_image = np.random.rand(32, 32)
Define a bilateral blur feature:
>>> import cv2 >>> >>> bilateral_blur = dt.BilateralBlur( ... d=5, ... sigma_color=50, ... sigma_space=50, ... mode='reflect', ... ) >>> output_image = bilateral_blur(input_image) >>> print(output_image.shape) (32, 32)