Sharpen the image via kernel or Gaussian unsharp method. alpha and lightness control strength. Enhances edges; useful for document or detail-sensitive tasks.
Implements two different approaches to image sharpening:
alphaRange 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).
lightnessRange 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).
methodSharpening algorithm to use:
kernel_sizeSize of the Gaussian blur kernel for 'gaussian' method. Must be odd. Default: 5
sigmaStandard deviation for Gaussian kernel in 'gaussian' method. Default: 1.0
pProbability of applying the transform. Default: 0.5.
>>> 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
... )