Color

class plugins.convert.color.color_transfer.Color(config_file=None, config=None)

Bases: Adjustment

Transfers the color distribution from the source to the target image using the mean and standard deviations of the L*a*b* color space.

This implementation is (loosely) based on to the “Color Transfer between Images” paper by Reinhard et al., 2001.

Methods Summary

image_stats(image)

process(old_face, new_face, raw_mask)

run(old_face, new_face, raw_mask)

Perform selected adjustment on face

Methods Documentation

static image_stats(image)
Parameters:

image (NumPy array) – OpenCV image in L*a*b* color space

Returns:

  • Tuple of mean and standard deviations for the L, a*, and b**

  • channels, respectively

process(old_face, new_face, raw_mask)
Parameters:
  • source (NumPy array) – OpenCV image in BGR color space (the source image)

  • target (NumPy array) – OpenCV image in BGR color space (the target image)

  • clip (Should components of L*a*b* image be scaled by np.clip before) – converting back to BGR color space? If False then components will be min-max scaled appropriately. Clipping will keep target image brightness truer to the input. Scaling will adjust image brightness to avoid washed out portions in the resulting color transfer that can be caused by clipping.

  • preserve_paper (Should color transfer strictly follow methodology) – layed out in original paper? The method does not always produce aesthetically pleasing results. If False then L*a*b* components will scaled using the reciprocal of the scaling factor proposed in the paper. This method seems to produce more consistently aesthetically pleasing results

Returns:

transfer – OpenCV image (w, h, 3) NumPy array (uint8)

Return type:

NumPy array

run(old_face, new_face, raw_mask)

Perform selected adjustment on face

static image_stats(image)
Parameters:

image (NumPy array) – OpenCV image in L*a*b* color space

Returns:

  • Tuple of mean and standard deviations for the L, a*, and b**

  • channels, respectively

process(old_face, new_face, raw_mask)
Parameters:
  • source (NumPy array) – OpenCV image in BGR color space (the source image)

  • target (NumPy array) – OpenCV image in BGR color space (the target image)

  • clip (Should components of L*a*b* image be scaled by np.clip before) – converting back to BGR color space? If False then components will be min-max scaled appropriately. Clipping will keep target image brightness truer to the input. Scaling will adjust image brightness to avoid washed out portions in the resulting color transfer that can be caused by clipping.

  • preserve_paper (Should color transfer strictly follow methodology) – layed out in original paper? The method does not always produce aesthetically pleasing results. If False then L*a*b* components will scaled using the reciprocal of the scaling factor proposed in the paper. This method seems to produce more consistently aesthetically pleasing results

Returns:

transfer – OpenCV image (w, h, 3) NumPy array (uint8)

Return type:

NumPy array