darsia.ColorCorrection#

class ColorCorrection(base=None, config=None)[source]#

Bases: BaseCorrection

Color correction with user-specified location of a color checker.

Precise user-input is required for detecting the color checker. The Calibrite/ X-rite color checker has four corner landmarks on the colorchecker. The pixel coordinates of these have to be provided as input parameters, starting with the corner close to the brown swatch, and continuing in counter-clockwise direction. The color correction is applied prior to curvature correction in the darsia.Image initialization, and therefore, the roi should be with respect to the uncorrected image.

Set up all data needed for fast colour conversion.

Parameters:
basedarsia.Image or ColorChecker, optional

Reference defining a colour checker; if None, a CustomColorChecker is used.

configdict, optional

Configuration. Recognised keys:

roi (tuple of slices | ndarray | None)
    ROI containing the colour checker, as intervals or corner
    points; an array of coordinates is recommended.
whitebalancing (bool)   default True; white-balance on the
                        third bottom-left swatch
verbosity (bool)        display the extracted ROIs and swatch
                        colours (debugging)

Methods

correct_array(img)

Similar workflow as by colour-science to match the colors of the color checker with the corresponding reference values, but tailored and simplified, based on the precise user-input on the location of the color checker.

correct_metadata([metadata])

Correction routine on metadata level.

load(path)

Load the color correction from a file.

save(path)

Save the color correction to a file.

write_config_to_file(path)

Writes the config dictionary to a json-file.

Attributes

config

Config dictionary for initialization of color correction.

correct_array(img)[source]#

Similar workflow as by colour-science to match the colors of the color checker with the corresponding reference values, but tailored and simplified, based on the precise user-input on the location of the color checker. Reference to the general workflow: colour-science/colour-checker-detection

Parameters:
imgnp.ndarray

Image in RGB space, with values in uint8, uint16, float32, or float64.

Returns:
np.ndarray

Corrected image.

load(path)[source]#

Load the color correction from a file.

Parameters:
pathPath

Path to the file.

save(path)[source]#

Save the color correction to a file.

Parameters:
pathPath

Path to the file.

write_config_to_file(path)[source]#

Writes the config dictionary to a json-file.

Parameters:
pathPath

Path to the json file.

config#

Config dictionary for initialization of color correction.