← Back to all transforms
Blur
Description
Apply uniform box blur to the input image using a randomly sized square kernel. This transform uses OpenCV's cv2.blur function, which performs a simple box filter blur. The size of the blur kernel is randomly selected for each application, allowing for varying degrees of blur intensity. Args: blur_limit (tuple[int, int] | int): Controls the range of the blur kernel size. - If a single int is provided, the kernel size will be randomly chosen between 3 and that value. - If a tuple of two ints is provided, it defines the inclusive range of possible kernel sizes. The kernel size must be odd and greater than or equal to 3. Larger kernel sizes produce stronger blur effects. Default: (3, 7) p (float): Probability of applying the transform. Default: 0.5 Notes: - The blur kernel is always square (same width and height). - Only odd kernel sizes are used to ensure the blur has a clear center pixel. - Box blur is faster than Gaussian blur but may produce less natural results. - This blur method averages all pixels under the kernel area, which can reduce noise but also reduce image detail. Targets: image Image types: uint8, float32 Example: >>> import numpy as np >>> import albumentations as A >>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8) >>> transform = A.Blur(blur_limit=(3, 7), p=1.0) >>> result = transform(image=image) >>> blurred_image = result["image"]
Parameters
- blur_limit: int | tuple[int, int] (default: (3, 7))
- p: float (default: 0.5)
Targets
- Image
Try it out
ⓘ
Original Image:
Result:
Transform result will appear here