educelab.imgproc.adjust

Functions which emulate common image editor adjustment functions.

educelab.imgproc.adjust.brightness(image, val)

Adjust image brightness.

Parameters:
  • image – Input image.

  • val – Brightness adjustment factor in units of the image’s dynamic range (+/-).

Returns:

Brightness-adjusted image.

educelab.imgproc.adjust.brightness_contrast(image: ndarray, b: float, c)

Apply a brightness-contrast adjustment.

Parameters:
  • image – Input image.

  • b – Brightness adjustment factor in units of the image’s dynamic range (+/-).

  • c – Contrast adjustment factor (+/-). Positives values increase contrast while negative values decrease contrast.

Returns:

Brightness/contrast-adjusted image.

educelab.imgproc.adjust.contrast(image, val: float)

Adjust image contrast.

Note that this is a simple contrast adjustment that corresponds to the Legacy method in Photoshop.

Parameters:
  • image – Input image.

  • val – Contrast adjustment factor (+/-). Positive values increase contrast while negative values decrease contrast. Values below -1 will invert the image.

Returns:

Contrast-adjusted image.

educelab.imgproc.adjust.exposure(image, val)

Increase image exposure.

Parameters:
  • image – Input image.

  • val – Exposure adjustment factor (+/-).

Returns:

Exposure-adjusted image.

educelab.imgproc.adjust.shadows(image, val)

Image shadow adjustment.

Adapted from an implementation by HViktorTsoi.

Parameters:
  • image – Input image.

  • val – Shadow adjustment factor (+/-).

Returns:

Exposure-adjusted image.

educelab.imgproc.adjust.shadows_highlights(img, shadows_gain, highlights_gain, blur_method='gaussian', whitepoint=0, compress=0.5, shadows_correct=1.0, highlights_correct=0.5, bilateral_radius: int = None, sigma: float = 1)

Image shadows and highlights correct. Ported from darktable.

Parameters:
  • img – Input image

  • shadows_gain – [-1, 1] Shadow adjustment.

  • highlights_gain – [-1, 1] Highlight adjustment.

  • blur_method – ‘bilateral’ or ‘gaussian’.

  • whitepoint – [-1, 1] White point adjustment.

  • compress – [0, 1] Controls effect on midtones. High values limit the effect to only the darkest and brightest values.

  • shadows_correct – [0, 1] Controls saturation effect on adjusted shadows.

  • highlights_correct – [0, 1] Controls saturation effect on adjusted highlights.

  • sigma – (0, inf) Std. dev. for Gaussian blur filter.

  • bilateral_radius – [5, inf) Radius of Bilateral filter kernel.