Sharpen

Targets:
image
volume
Image Types:uint8, float32

Sharpen the input image using either kernel-based or Gaussian interpolation method.

Implements two different approaches to image sharpening:

  1. Traditional kernel-based method using Laplacian operator
  2. Gaussian interpolation method (similar to Kornia's approach)
Arguments
alpha
tuple[float, float]
[0.2,0.5]

Range for the visibility of sharpening effect. At 0, only the original image is visible, at 1.0 only its processed version is visible. Values should be in the range [0, 1]. Used in both methods. Default: (0.2, 0.5).

lightness
tuple[float, float]
[0.5,1]

Range for the lightness of the sharpened image. Only used in 'kernel' method. Larger values create higher contrast. Values should be greater than 0. Default: (0.5, 1.0).

method
kernel | gaussian
kernel

Sharpening algorithm to use:

  • 'kernel': Traditional kernel-based sharpening using Laplacian operator
  • 'gaussian': Interpolation between Gaussian blurred and original image Default: 'kernel'
kernel_size
int
5

Size of the Gaussian blur kernel for 'gaussian' method. Must be odd. Default: 5

sigma
float
1

Standard deviation for Gaussian kernel in 'gaussian' method. Default: 1.0

p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> import albumentations as A
>>> import numpy as np

# Traditional kernel sharpening
>>> transform = A.Sharpen(
...     alpha=(0.2, 0.5),
...     lightness=(0.5, 1.0),
...     method='kernel',
...     p=1.0
... )

# Gaussian interpolation sharpening
>>> transform = A.Sharpen(
...     alpha=(0.5, 1.0),
...     method='gaussian',
...     kernel_size=5,
...     sigma=1.0,
...     p=1.0
... )
Notes
  • Kernel sizes must be odd to maintain spatial alignment
  • Methods produce different visual results:
    • Kernel method: More pronounced edges, possible artifacts
    • Gaussian method: More natural look, limited to original sharpness
See Also
  • Blur: For Gaussian blurring
  • UnsharpMask: Alternative sharpening method
  • RandomBrightnessContrast: For adjusting image contrast
References