← Back to all transforms
AdvancedBlur
Description
Applies a Generalized Gaussian blur to the input image with randomized parameters for advanced data augmentation. This transform creates a custom blur kernel based on the Generalized Gaussian distribution, which allows for a wide range of blur effects beyond standard Gaussian blur. It then applies this kernel to the input image through convolution. The transform also incorporates noise into the kernel, resulting in a unique combination of blurring and noise injection. Key features of this augmentation: 1. Generalized Gaussian Kernel: Uses a generalized normal distribution to create kernels that can range from box-like blurs to very peaked blurs, controlled by the beta parameter. 2. Anisotropic Blurring: Allows for different blur strengths in horizontal and vertical directions (controlled by sigma_x and sigma_y), and rotation of the kernel. 3. Kernel Noise: Adds multiplicative noise to the kernel before applying it to the image, creating more diverse and realistic blur effects. Implementation Details: The kernel is generated using a 2D Generalized Gaussian function. The process involves: 1. Creating a 2D grid based on the kernel size 2. Applying rotation to this grid 3. Calculating the kernel values using the Generalized Gaussian formula 4. Adding multiplicative noise to the kernel 5. Normalizing the kernel The resulting kernel is then applied to the image using convolution. Args: blur_limit (tuple[int, int] | int, optional): Controls the size of the blur kernel. If a single int is provided, the kernel size will be randomly chosen between 3 and that value. Must be odd and ≥ 3. Larger values create stronger blur effects. Default: (3, 7) sigma_x_limit (tuple[float, float] | float): Controls the spread of the blur in the x direction. Higher values increase blur strength. If a single float is provided, the range will be (0, limit). Default: (0.2, 1.0) sigma_y_limit (tuple[float, float] | float): Controls the spread of the blur in the y direction. Higher values increase blur strength. If a single float is provided, the range will be (0, limit). Default: (0.2, 1.0) rotate_limit (tuple[int, int] | int): Range of angles (in degrees) for rotating the kernel. This rotation allows for diagonal blur directions. If limit is a single int, an angle is picked from (-rotate_limit, rotate_limit). Default: (-90, 90) beta_limit (tuple[float, float] | float): Shape parameter of the Generalized Gaussian distribution. - beta = 1 gives a standard Gaussian distribution - beta < 1 creates heavier tails, resulting in more uniform, box-like blur - beta > 1 creates lighter tails, resulting in more peaked, focused blur Default: (0.5, 8.0) noise_limit (tuple[float, float] | float): Controls the strength of multiplicative noise applied to the kernel. Values around 1.0 keep the original kernel mostly intact, while values further from 1.0 introduce more variation. Default: (0.75, 1.25) p (float): Probability of applying the transform. Default: 0.5 Notes: - This transform is particularly useful for simulating complex, real-world blur effects that go beyond simple Gaussian blur. - The combination of blur and noise can help in creating more robust models by simulating a wider range of image degradations. - Extreme values, especially for beta and noise, may result in unrealistic effects and should be used cautiously. Reference: This transform is inspired by techniques described in: "Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data" https://arxiv.org/abs/2107.10833 Targets: image Image types: uint8, float32
Parameters
- blur_limit: int | tuple[int, int] (default: (3, 7))
- sigma_x_limit: int | tuple[int, int] | float | tuple[float, float] (default: (0.2, 1))
- sigma_y_limit: int | tuple[int, int] | float | tuple[float, float] (default: (0.2, 1))
- rotate_limit: int | tuple[int, int] | float | tuple[float, float] (default: (-90, 90))
- beta_limit: int | tuple[int, int] | float | tuple[float, float] (default: (0.5, 8))
- noise_limit: int | tuple[int, int] | float | tuple[float, float] (default: (0.9, 1.1))
- p: float (default: 0.5)
Targets
- Image
Try it out
ⓘ
Original Image:
Result:
Transform result will appear here