예제 #1
0
def find_colour(spectrum, col_map_f='CIE 1931 2 Degree Standard Observer'):

    import colour

    cmfs = colour.MSDS_CMFS[col_map_f]
    illuminant = colour.SDS_ILLUMINANTS['D65']

    wavs = spectrum.wavelengths

    try:
        XYZ = colour.sd_to_XYZ(spectrum, cmfs, illuminant)
    except:
        XYZ = colour.sd_to_XYZ(
            spectrum.interpolate(colour.SpectralShape(min(wavs), max(wavs),
                                                      1)), cmfs, illuminant)

    RGB = colour.XYZ_to_sRGB(XYZ / 100)

    for i in range(0, 3, 1):
        if RGB[i] < 0:
            RGB[i] = 0
        if RGB[i] > 1:
            RGB[i] = 1

    return RGB
예제 #2
0
def plot_patches(FileName, PatchesXYZ, BackgroundColour):
    #dont know what this does
    fig, ax = plt.subplots()
    #background grey
    background_rect = mpathes.Rectangle([0.0, 0.0],
                                        0.3 + len(patches) * 0.3,
                                        0.32,
                                        color=BackgroundColour)
    ax.add_patch(background_rect)
    #Draw all patches
    patch_count = 0
    for patch in PatchesXYZ:
        rgb = colour.XYZ_to_sRGB(patch)
        ax.add_patch(
            mpathes.Rectangle([0.2 + patch_count * 0.3, 0.06],
                              0.2,
                              0.2,
                              color=colour.notation.RGB_to_HEX(rgb)))
        patch_count += 1
    # Save image
    plt.axis('scaled')
    plt.axis('off')
    plt.tight_layout()
    plt.savefig(FileName,
                dpi=500,
                bbox_inches='tight',
                pad_inches=0,
                transparent=True)
예제 #3
0
def spectral2rgb(s):
    sd = colour.SpectralDistribution(s)
    cmfs = colour.STANDARD_OBSERVERS_CMFS[
        'CIE 1931 2 Degree Standard Observer']
    illuminant = colour.ILLUMINANTS_SDS['D65']
    XYZ = colour.sd_to_XYZ(sd, cmfs, illuminant)
    RGB = colour.XYZ_to_sRGB(XYZ / 100)
    return RGB
예제 #4
0
def convert(dict, illuminant='D65'):
    """ Converts the set of XYZ colours into other spaces: Lab, LCH, sRGB """
    illuminant = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][
        illuminant]
    dict['Lab'] = colour.XYZ_to_Lab(dict['XYZ'] / 100.,
                                    illuminant)  # beware: expects XYZ in [0,1]
    dict['LCH'] = colour.Lab_to_LCHab(dict['Lab'])
    dict['RGB'] = colour.XYZ_to_sRGB(
        dict['XYZ'] / 100., illuminant)  # beware: expects XYZ in [0,1]
예제 #5
0
파일: FunctionsTRA.py 프로젝트: den200x/gui
def calculateColorValues(splineT, splineR, settings):
    '''Function calculates color values of the Transmission and Refelection side of the stack. 
    Input Arguments are tranmission and reflection spline functions.
    Returns array of values/tuples of different standards.'''
    import colour
    import numpy as np
    wvl = np.linspace(380, 780, 81)
    dic_T = {}
    dic_R = {}
    dic_test = {}
    for idx, value in enumerate(wvl):
        dic_T[value] = splineT(value).item()
        dic_R[value] = splineR(value).item()

    #Removes warnings from conversions.
    colour.filter_warnings()
    cmfs = colour.STANDARD_OBSERVERS_CMFS[settings.color_cmfs]  #1931 etc
    illuminant = colour.ILLUMINANTS_RELATIVE_SPDS[
        settings.color_illuminant]  #D65, A, C

    T_spd = colour.SpectralPowerDistribution('', dic_T)
    T_XYZ = colour.spectral_to_XYZ(T_spd, cmfs, illuminant)
    T_xy = colour.XYZ_to_xy(T_XYZ / 100)
    T_ab = colour.XYZ_to_Lab(T_XYZ / 100,
                             illuminant=colour.ILLUMINANTS[settings.color_cmfs]
                             [settings.color_illuminant])
    T_rgb = colour.XYZ_to_sRGB(
        T_XYZ / 100,
        illuminant=colour.ILLUMINANTS[settings.color_cmfs][
            settings.color_illuminant])

    R_spd = colour.SpectralPowerDistribution('', dic_R)
    R_XYZ = colour.spectral_to_XYZ(R_spd, cmfs, illuminant)
    R_xy = colour.XYZ_to_xy(R_XYZ / 100)
    R_ab = colour.XYZ_to_Lab(R_XYZ / 100,
                             illuminant=colour.ILLUMINANTS[settings.color_cmfs]
                             [settings.color_illuminant])
    R_rgb = colour.XYZ_to_sRGB(
        R_XYZ / 100,
        illuminant=colour.ILLUMINANTS[settings.color_cmfs][
            settings.color_illuminant])

    return (T_XYZ, T_xy, T_ab, T_rgb, R_XYZ, R_xy, R_ab, R_rgb)
예제 #6
0
def set_convertor(name, ill='D65'):
    """ Binds the conversion functions LCH2RGB() and RGB2LCH() to the choosen colour package
    """
    global LCH2RGB, RGB2LCH, convertor, illuminant
    if name not in ['custom', 'colorspacious', 'colourscience']:
        print("Unknown conversion module")
        return
    convertor = name
    illuminant = ill
    if name == 'custom':
        LCH2RGB = lambda L, C, H: XYZ2RGB(Lab2XYZ(LCH2Lab((L, C, H))))
        RGB2LCH = lambda R, G, B: Lab2LCH(XYZ2Lab(RGB2XYZ((R, G, B))))
    if name == 'colorspacious':
        from colorspacious import cspace_convert
        func_LCH2RGB = lambda L, C, H: cspace_convert([L, C, H], {
            "name": "CIELCh",
            "XYZ100_w": ill
        }, "sRGB1")
        func_RGB2LCH = lambda R, G, B: cspace_convert([R, G, B], "sRGB1", {
            "name": "CIELCh",
            "XYZ100_w": ill
        })
    if name == 'colourscience':
        import colour as cs
        cs_ill = cs.ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][ill]
        func_LCH2RGB = lambda L, C, H: cs.XYZ_to_sRGB(
            cs.Lab_to_XYZ(cs.LCHab_to_Lab([L, C, H]), illuminant=cs_ill))
        func_RGB2LCH = lambda R, G, B: cs.Lab_to_LCHab(
            cs.XYZ_to_Lab(cs.sRGB_to_XYZ([R, G, B]), illuminant=cs_ill))
    if name == 'colorspacious' or name == 'colourscience':

        def LCH2RGB(L, C, H):
            if hasattr(L, '__iter__'):
                RGB = np.array(list(map(func_LCH2RGB, L, C, H)))
                R = RGB[:, 0]
                G = RGB[:, 1]
                B = RGB[:, 2]
            else:
                R, G, B = func_LCH2RGB(L, C, H)
            return R, G, B

        def RGB2LCH(R, G, B):
            if hasattr(R, '__iter__'):
                LCH = np.array(list(map(func_RGB2LCH, R, G, B)))
                L = LCH[:, 0]
                C = LCH[:, 1]
                H = LCH[:, 2]
            else:
                L, C, H = func_RGB2LCH(R, G, B)
            return L, C, H

    print("convertor = '%s' (illuminant = '%s')" % (name, illuminant))
예제 #7
0
def prepare_cc():
    print(colour.COLOURCHECKERS.data.keys())
    cc = []
    for i in range(0, 24):
        xyY = colour.COLOURCHECKERS.data['colorchecker 2005'][1].data[i].xyY
        print(colour.COLOURCHECKERS.data['colorchecker 2005'][1].data[i].name)
        print(xyY)
        XYZ = colour.xyY_to_XYZ(xyY)
        Lab = colour.XYZ_to_Lab(XYZ)
        print(
            colour.XYZ_to_sRGB(
                XYZ, colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
                ['D50'], 'Bradford') * 255)
        # print(colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50'])
        XYZD65 = cam2xyz.XYZD50_XYZD65(XYZ)
        cc.append(XYZD65)
        print(XYZD65, ' ', colour.XYZ_to_sRGB(XYZD65) * 255)
        # print(XYZ, ' ' ,XYZD65)
        # print(colour.RGB_COLOURSPACES['sRGB'].whitepoint, ' ', ill2)
        # print(colour.XYZ_to_sRGB(XYZD65) * 255)
        # print(colour.COLOURCHECKERS.data['cc2005'][1].data[i])
    return cc
예제 #8
0
def my_HVC2RGB(HVC):
    xyY = colour.munsell_colour_to_xyY(HVC)
    XYZ = colour.xyY_to_XYZ(xyY)
    # The last step will involve using the *Munsell Renotation System*
    # illuminant which is *CIE Illuminant C*:
    # http://nbviewer.ipython.org/github/colour-science/colour-ipython/blob/master/notebooks/colorimetry/illuminants.ipynb#CIE-Illuminant-C
    # It is necessary in order to ensure white stays white when
    # converting to *sRGB* colourspace and its different whitepoint
    # (*CIE Standard Illuminant D65*) by performing chromatic
    # adaptation between the two different illuminant.
    rgb = colour.XYZ_to_sRGB(XYZ, C)
    RGB = [np.uint8(round(255 * x)) for x in rgb]
    return RGB
예제 #9
0
파일: adds.py 프로젝트: jhasanov/ACV
def LAB2RGB(image):
    """
    Convert image from CIE Lab to RGB colour space
    Lab   Scale
    L|    0:100 |
    a| -100:100 |
    b| -100:100 |

    :param image:
    :return:
    """
    image_sRGB = colour.XYZ_to_sRGB(colour.Lab_to_XYZ(image))
    image_RGB = np.round(image_sRGB * 255).astype(np.uint8)
    return image_RGB
def wavelength_to_rgb(wavelength: float,
                      gamma: float = 2.4) -> Tuple[int, int, int]:
    """
    Converts a wavelength (in nanometres) to a gamma corrected RGB tuple with values [0, 255].
    Returns white if the wavelength is outside the visible spectrum or any other error occurs.
    """

    try:
        xyz = colour.wavelength_to_XYZ(wavelength)
        srgb = colour.XYZ_to_sRGB(xyz).clip(0, 1)
        gamma_corrected_rgb = 255 * srgb**(1 / gamma)
        return tuple(gamma_corrected_rgb)
    except ValueError:
        return 255, 255, 255
예제 #11
0
def find_colour_single(wl):
    import colour
    from colour.colorimetry import wavelength_to_XYZ

    if wl < 360 or wl > 830:
        RGB = (0, 0, 0)
    else:
        XYZ = wavelength_to_XYZ(wl)
        RGB = colour.XYZ_to_sRGB(XYZ)
        for i in range(0, 3, 1):
            if RGB[i] < 0:
                RGB[i] = 0
            if RGB[i] > 1:
                RGB[i] = 1
    return (RGB)
예제 #12
0
	def temperatureChange(self):	
		value = self.temperatureSlider.value() +1
		#range is 1100K to 11 000K
		K = int(1000+ (value*120))
		print("Kelvins: ", K)
		xy = colour.CCT_to_xy(K)
		#print("xy", xy)
		xyz = colour.xy_to_XYZ(xy)
		#print("xyz", xyz)
		rgb = colour.XYZ_to_sRGB(xyz)
		r = int(min(1,max(0,rgb[0]))*255)
		g = int(min(1,max(0,rgb[1]))*255)
		b = int(min(1,max(0,rgb[2]))*255)
		self.color = [r, g, b]
		print("rgb", self.color)
		self.updateColorLabel()
예제 #13
0
def wavelengthToHex(wavelength: float, gamma: float = 2.4):
    """
    Converts a wavelength (in nanometres) to a gamma corrected RGB tuple with values [0, 255].
    Returns white if the wavelength is outside the visible spectrum or any other error occurs.
    """

    try:
        xyz = colour.wavelength_to_XYZ(wavelength)
        srgb = colour.XYZ_to_sRGB(xyz).clip(0, 1)
        gamma_corrected_rgb = 255 * srgb**(1 / gamma)
        chex = '#%02x%02x%02x' % (int(
            gamma_corrected_rgb[0]), int(
                gamma_corrected_rgb[1]), int(gamma_corrected_rgb[2]))
        return chex
    except ValueError:
        return 255, 255, 255
예제 #14
0
    def paint(self, cr):
        area = self._get_area()
        if area is not None:
            x, y, w, h = area
            # if we're picking an illuminant splash that instead of brush color
            if self._pickmode == "PickIlluminant":
                p = self.app.preferences
                xyz = p['color.dimension_lightsource_XYZ']
                ill = colour.XYZ_to_sRGB(np.array(xyz)/100.0)
                cr.set_source_rgb(*ill)
            elif self.blending_color is not None:
                cr.set_source_rgb(*self.blending_color.get_rgb())
            elif self._pickmode == "PickTarget":
                cr.set_source_rgb(*self._doc.last_color_target.get_rgb())
            else:
                cr.set_source_rgb(*self._color.get_rgb())
            x += (self.OUTLINE_WIDTH // 2) + 1.5
            y += (self.OUTLINE_WIDTH // 2) + 1.5
            w -= self.OUTLINE_WIDTH + 3
            h -= self.OUTLINE_WIDTH + 3
            
            if self._pickmode == "PickandBlend":
                rounded_box_hole(cr, x, y, w, h, self.corner_radius)
                cr.set_fill_rule(cairo.FILL_RULE_EVEN_ODD)
            else:
                rounded_box(cr, x, y, w, h, self.corner_radius)
            cr.fill_preserve()
            # don't outline when blending, will detract from
            # color comparisons
            if self.blending_ratio is None:
                cr.set_source_rgb(0, 0, 0)
                cr.set_line_width(self.OUTLINE_WIDTH)
            cr.stroke()
            # TODO make this an overlay like the Scale overlay
            # Ugly percentage text box
#            if self.blending_ratio is not None:
#                cr.move_to(x + 5, y + 20)
#                cr.select_font_face('Sans')
#                cr.set_font_size(20) # em-square height is 90 pixels
#                cr.text_path(str(int(self.blending_ratio * 100)) + '%')
#                cr.set_source_rgb(1, 1, 1)
#                cr.fill_preserve()
#                cr.set_source_rgb(0, 0, 0)
#                cr.set_line_width(1.0)
#                cr.stroke()

        self._previous_area = area
예제 #15
0
def temperature_to_rgb(cct):
    """ Convert temperature in Kelvin to sRGB.
    First, we convert CCT (Kelvin) to chromaticity coordinates.
    Second, we convert to tristimulus values.
    Third, we convert to rgb

    Parameters
    ----------
    cct : Correlated color temperature in kelvin

    Returns
    -------
    array : List/tuple of rgb values, e.g. [255.0, 235.0, 12.0]
    """
    xy = colour.CCT_to_xy(cct)
    xyz = colour.xy_to_XYZ(xy)
    rgb = colour.XYZ_to_sRGB(xyz)
    return rgb
예제 #16
0
    def compute_color(self):
        self.sample_spd_data = dict(zip(self.raw_wl, self.raw_spec))
        self.spd = colour.SpectralDistribution(self.sample_spd_data,
                                               name=self.label)
        # Cloning the sample spectral power distribution.
        self.spd_interpolated = self.spd.clone()

        # Interpolating the cloned sample spectral power distribution.
        # Indeed, the algorithm for colour identification needs a spectra with a point each nanometer
        self.spd_interpolated.interpolate(colour.SpectralShape(370, 680, 1))

        self.cmfs = colour.STANDARD_OBSERVERS_CMFS[
            'CIE 1931 2 Degree Standard Observer']
        self.illuminant = colour.ILLUMINANTS_SDS['D65']
        self.XYZ = colour.sd_to_XYZ(self.spd_interpolated, self.cmfs,
                                    self.illuminant)
        self.RGB = colour.XYZ_to_sRGB(self.XYZ / 100)
        """
        We then come to the next obstacle...  The RGB values that we get from this process are often out of range - 
        meaning that they are either greater than 1.0, or even that they are negative!  The first case is fairly 
        straightforward, it means that the color is too bright for the display.  The second case means that the color 
        is too saturated and vivid for the display.  The display must compose all colors from some combination of 
        positive amounts of the colors of its red, green and blue phosphors.  The colors of these phosphors are not 
        perfectly saturated, they are washed out, mixed with white, to some extent.  So not all colors can be displayed 
        accurately.  As an example, the colors of pure spectral lines, all have some negative component.  
        Something must be done to put these values into the 0.0 - 1.0 range that can actually be displayed, 
        known as color clipping.
        
        In the first case, values larger than 1.0, ColorPy scales the color so that the maximum component is 1.0.  
        This reduces the brightness without changing the chromaticity.  The second case requires some change in 
        chromaticity.  By default, ColorPy will add white to the color, just enough to make all of the components 
        non-negative.  (You can also have ColorPy clamp the negative values to zero.  My personal, qualitative, 
        assessment is that adding white produces somewhat better results.  There is also the potential to develop a 
        better clipping function.)
        """
        if min(self.RGB) < 0:
            self.RGB += min(self.RGB)
        if max(self.RGB) > 1:
            self.RGB /= max(self.RGB)

        # TODO why can we get negative values and values > 1 ?
        self.RGB = np.abs(self.RGB)
        self.RGB = np.clip(self.RGB, 0, 1)
        self.xy = colour.XYZ_to_xy(self.XYZ)
예제 #17
0
def get_tristimulus_XYZs(Theta_I, Phi_I, Polarization, Data, observer,
                         illuminant):
    u_wls = np.array(Data['Wavelengths'])
    u_theta_Is = np.array(Data['thetaIs'])
    u_phi_Is = np.array(Data['phiIs'])
    u_pols = np.array(Data['Polarization'])
    u_theta_Vs = np.array(Data['thetaVs'])
    u_phi_Vs = np.array(Data['phiVs'])
    data = np.array(Data['data'])

    cmfs = clr.STANDARD_OBSERVERS_CMFS[observer]
    illuminant = clr.ILLUMINANTS_SDS[illuminant]
    tristimulus_XYZ_values = []
    color_values = []
    for theta_V in u_theta_Vs:
        tristimulus_XYZ_row = []
        color_values_row = []
        for phi_V in u_phi_Vs:
            spectrum = data[u_pols == Polarization, u_theta_Is == Theta_I,
                            u_phi_Is == Phi_I, :, u_theta_Vs == theta_V,
                            u_phi_Vs == phi_V]
            # spectrum = spectrum[0]/np.max(spectrum)
            spectrum = np.array([u_wls, spectrum[0]]).T
            spectrum = spectrum.tolist()
            spectrum = {line[0]: line[1] for line in spectrum}
            sd = clr.SpectralDistribution(spectrum)
            sd = sd.interpolate(clr.SpectralShape(380, 830, 1))
            # print(sd)
            XYZ = clr.sd_to_XYZ(sd, cmfs, illuminant)
            sRGB = clr.XYZ_to_sRGB(XYZ / 100)
            sRGB = sRGBColor(sRGB[0], sRGB[1], sRGB[2])
            RGB = list(sRGB.get_upscaled_value_tuple())
            for i in range(len(RGB)):
                if RGB[i] < 0:
                    RGB[i] = 0
                elif RGB[i] > 255:
                    RGB[i] = 255
            tristimulus_XYZ_row.append(XYZ)
            color_values_row.append(RGB)
        tristimulus_XYZ_values.append(tristimulus_XYZ_row)
        color_values.append(color_values_row)
    return tristimulus_XYZ_values, color_values
예제 #18
0
    def copute_color(self):
        self.sample_spd_data = dict(zip(self.raw_wl, self.raw_spec))
        self.spd = colour.SpectralDistribution(self.sample_spd_data,
                                               name=self.label)
        # Cloning the sample spectral power distribution.
        self.spd_interpolated = self.spd.clone()

        # Interpolating the cloned sample spectral power distribution.
        # Indeed, the algorithm for colour identification needs a spectra with a point each nanometer
        self.spd_interpolated.interpolate(colour.SpectralShape(400, 820, 1))

        self.cmfs = colour.STANDARD_OBSERVERS_CMFS[
            'CIE 1931 2 Degree Standard Observer']
        self.illuminant = colour.ILLUMINANTS_SDS['D65']
        self.XYZ = colour.sd_to_XYZ(self.spd_interpolated, self.cmfs,
                                    self.illuminant)
        self.RGB = colour.XYZ_to_sRGB(self.XYZ / 100)
        # TODO why can we get negative values and values > 1 ?
        self.RGB = np.abs(self.RGB)
        self.RGB = np.clip(self.RGB, 0, 1)
        self.xy = colour.XYZ_to_xy(self.XYZ)
예제 #19
0
    def to_color(self):
        """
        Determine the RGB color of this spectrum.

        Returns
        -------
        rgb : numpy.ndarray
            3-element array containing RGB values
            that can be fed into matplotlib.
        """

        with warnings.catch_warnings():
            warnings.simplefilter(action="ignore", category=ColourRuntimeWarning)

            # create a colour SpectralDistribution
            sd = self.to_sd()

            # convert to XYZ
            # (maybe use `k=` option for relative scaling between sources?)
            XYZ = colour.sd_to_XYZ(sd)
            if (np.min(XYZ) < 0) or np.max(XYZ) > 100:
                print(f"XYZ={XYZ} is outside of [0, 100]!")

            # convert to RGB
            RGB = colour.XYZ_to_sRGB(XYZ / 100)
            if (np.min(RGB) < 0) or np.max(RGB) > 1:
                pass
                # print(f'RGB={RGB} is outside of [0, 1]!')

            # trim out underenderable colors (this is sneaky!)
            # clipped_RGB = np.maximum(0, np.minimum(1, RGB))
            clipped_RGB = np.maximum(0, RGB)
            # instead of clip, should we add to everything until we get to zero?

            # kludge to maximize brightness, for every color!
            clipped_RGB /= np.max(clipped_RGB)
            return clipped_RGB
예제 #20
0
def _ciexyz_to_rgb(img: np.ndarray,
                   backend: Optional[str] = None,
                   **kwargs: Any) -> np.ndarray:
    """ not finished, not checked,

    convert `img` from the color space of CIEXYZ to the color space of RGB

    Parameters
    ----------
    img: ndarray,
        the image, in the format (color space) CIEXYZ, be converted to RGB
    backend: str, default `_CVT_COLOR_BACKEND`, currently can be one in `_AVAILABLE_CVT_COLOR_BACKENDS`,
        the backend to perform the color space conversion
    kwargs: dict,
        not used, only to be compatible with other color space conversion functions

    Returns
    -------
    rgb: ndarray,
        `img` in the format (color space) of RGB
    """
    if backend is None:
        # backend = _CVT_COLOR_BACKEND  # no such method in cv2
        backend = "colour-science"
    if backend.lower() == "cv2":
        pass
    elif backend.lower() == "colour-science":
        rgb = colour.XYZ_to_sRGB(img)
        # srgb to 8bit RGB
    elif backend.lower() == "pil":
        pass
    elif backend.lower() == "naive":
        # default_white_point = np.array([0.3127, 0.3290, 0.0])
        # img_xyz = _rgb_to_ciexyz(img=img, backend=backend, **kwargs)
        pass
    return rgb
예제 #21
0
print(
    colour.RGB_to_XYZ(
        RGB,
        colour.RGB_COLOURSPACES['sRGB'].whitepoint,
        D65,
        colour.RGB_COLOURSPACES['sRGB'].RGB_to_XYZ_matrix,
        'Bradford',
        colour.RGB_COLOURSPACES['sRGB'].cctf_decoding,
    ))

print('\n')

message_box(('Converting to "sRGB" colourspace from given "CIE XYZ" '
             'tristimulus values using convenient definition:\n'
             '\n\t{0}'.format(XYZ)))
print(colour.XYZ_to_sRGB(XYZ, D65))

print('\n')

message_box(('Converting to "CIE 1960 UCS" colourspace from given "CIE XYZ" '
             'tristimulus values:\n'
             '\n\t{0}'.format(XYZ)))
print(colour.XYZ_to_UCS(XYZ))

print('\n')

UCS = np.array([0.07049533, 0.10080000, 0.09558313])
message_box(('Converting to "CIE XYZ" tristimulus values from given'
             '"CIE 1960 UCS" colourspace values:\n'
             '\n\t{0}'.format(UCS)))
print(colour.UCS_to_XYZ(UCS))
예제 #22
0
def generate_documentation_plots(output_directory):
    """
    Generates documentation plots.

    Parameters
    ----------
    output_directory : unicode
        Output directory.
    """

    colour.utilities.filter_warnings()

    colour_style()

    np.random.seed(0)

    # *************************************************************************
    # "README.rst"
    # *************************************************************************
    arguments = {
        'tight_layout':
            True,
        'transparent_background':
            True,
        'filename':
            os.path.join(output_directory,
                         'Examples_Plotting_Visible_Spectrum.png')
    }
    plot_visible_spectrum('CIE 1931 2 Degree Standard Observer', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Examples_Plotting_Illuminant_F1_SD.png')
    plot_single_illuminant_sd('FL1', **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Examples_Plotting_Blackbodies.png')
    blackbody_sds = [
        colour.sd_blackbody(i, colour.SpectralShape(0, 10000, 10))
        for i in range(1000, 15000, 1000)
    ]
    plot_multi_sds(
        blackbody_sds,
        y_label='W / (sr m$^2$) / m',
        use_sds_colours=True,
        normalise_sds_colours=True,
        legend_location='upper right',
        bounding_box=(0, 1250, 0, 2.5e15),
        **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Examples_Plotting_Cone_Fundamentals.png')
    plot_single_cmfs(
        'Stockman & Sharpe 2 Degree Cone Fundamentals',
        y_label='Sensitivity',
        bounding_box=(390, 870, 0, 1.1),
        **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Examples_Plotting_Luminous_Efficiency.png')
    sd_mesopic_luminous_efficiency_function = (
        colour.sd_mesopic_luminous_efficiency_function(0.2))
    plot_multi_sds(
        (sd_mesopic_luminous_efficiency_function,
         colour.PHOTOPIC_LEFS['CIE 1924 Photopic Standard Observer'],
         colour.SCOTOPIC_LEFS['CIE 1951 Scotopic Standard Observer']),
        y_label='Luminous Efficiency',
        legend_location='upper right',
        y_tighten=True,
        margins=(0, 0, 0, .1),
        **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Examples_Plotting_BabelColor_Average.png')
    plot_multi_sds(
        colour.COLOURCHECKERS_SDS['BabelColor Average'].values(),
        use_sds_colours=True,
        title=('BabelColor Average - '
               'Spectral Distributions'),
        **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Examples_Plotting_ColorChecker_2005.png')
    plot_single_colour_checker(
        'ColorChecker 2005', text_parameters={'visible': False}, **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Examples_Plotting_Chromaticities_Prediction.png')
    plot_corresponding_chromaticities_prediction(2, 'Von Kries', 'Bianco',
                                                 **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Examples_Plotting_CCT_CIE_1960_UCS_Chromaticity_Diagram.png')
    plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(['A', 'B', 'C'],
                                                            **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Examples_Plotting_Chromaticities_CIE_1931_Chromaticity_Diagram.png')
    RGB = np.random.random((32, 32, 3))
    plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(
        RGB,
        'ITU-R BT.709',
        colourspaces=['ACEScg', 'S-Gamut'],
        show_pointer_gamut=True,
        **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Examples_Plotting_CRI.png')
    plot_single_sd_colour_rendering_index_bars(colour.ILLUMINANTS_SDS['FL2'],
                                               **arguments)

    # *************************************************************************
    # Documentation
    # *************************************************************************
    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_CVD_Simulation_Machado2009.png')
    plot_cvd_simulation_Machado2009(RGB, **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_Colour_Checker.png')
    plot_single_colour_checker('ColorChecker 2005', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Multi_Colour_Checkers.png')
    plot_multi_colour_checkers(['ColorChecker 1976', 'ColorChecker 2005'],
                               **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Single_SD.png')
    data = {
        500: 0.0651,
        520: 0.0705,
        540: 0.0772,
        560: 0.0870,
        580: 0.1128,
        600: 0.1360
    }
    sd = colour.SpectralDistribution(data, name='Custom')
    plot_single_sd(sd, **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Multi_SDs.png')
    data_1 = {
        500: 0.004900,
        510: 0.009300,
        520: 0.063270,
        530: 0.165500,
        540: 0.290400,
        550: 0.433450,
        560: 0.594500
    }
    data_2 = {
        500: 0.323000,
        510: 0.503000,
        520: 0.710000,
        530: 0.862000,
        540: 0.954000,
        550: 0.994950,
        560: 0.995000
    }
    spd1 = colour.SpectralDistribution(data_1, name='Custom 1')
    spd2 = colour.SpectralDistribution(data_2, name='Custom 2')
    plot_multi_sds([spd1, spd2], **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Single_CMFS.png')
    plot_single_cmfs('CIE 1931 2 Degree Standard Observer', **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Multi_CMFS.png')
    cmfs = ('CIE 1931 2 Degree Standard Observer',
            'CIE 1964 10 Degree Standard Observer')
    plot_multi_cmfs(cmfs, **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_Illuminant_SD.png')
    plot_single_illuminant_sd('A', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Multi_Illuminant_SDs.png')
    plot_multi_illuminant_sds(['A', 'B', 'C'], **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Visible_Spectrum.png')
    plot_visible_spectrum(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_Lightness_Function.png')
    plot_single_lightness_function('CIE 1976', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Multi_Lightness_Functions.png')
    plot_multi_lightness_functions(['CIE 1976', 'Wyszecki 1963'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_Luminance_Function.png')
    plot_single_luminance_function('CIE 1976', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Multi_Luminance_Functions.png')
    plot_multi_luminance_functions(['CIE 1976', 'Newhall 1943'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Blackbody_Spectral_Radiance.png')
    plot_blackbody_spectral_radiance(
        3500, blackbody='VY Canis Major', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Blackbody_Colours.png')
    plot_blackbody_colours(colour.SpectralShape(150, 12500, 50), **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_Colour_Swatch.png')
    RGB = ColourSwatch(RGB=(0.32315746, 0.32983556, 0.33640183))
    plot_single_colour_swatch(RGB, **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Multi_Colour_Swatches.png')
    RGB_1 = ColourSwatch(RGB=(0.45293517, 0.31732158, 0.26414773))
    RGB_2 = ColourSwatch(RGB=(0.77875824, 0.57726450, 0.50453169))
    plot_multi_colour_swatches([RGB_1, RGB_2], **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Single_Function.png')
    plot_single_function(lambda x: x ** (1 / 2.2), **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Multi_Functions.png')
    functions = {
        'Gamma 2.2': lambda x: x ** (1 / 2.2),
        'Gamma 2.4': lambda x: x ** (1 / 2.4),
        'Gamma 2.6': lambda x: x ** (1 / 2.6),
    }
    plot_multi_functions(functions, **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Image.png')
    path = os.path.join(colour.__path__[0], '..', 'docs', '_static',
                        'Logo_Medium_001.png')
    plot_image(colour.read_image(str(path)), **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Corresponding_Chromaticities_Prediction.png')
    plot_corresponding_chromaticities_prediction(1, 'Von Kries', 'CAT02',
                                                 **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Spectral_Locus.png')
    plot_spectral_locus(spectral_locus_colours='RGB', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Chromaticity_Diagram_Colours.png')
    plot_chromaticity_diagram_colours(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Chromaticity_Diagram.png')
    plot_chromaticity_diagram(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Chromaticity_Diagram_CIE1931.png')
    plot_chromaticity_diagram_CIE1931(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Chromaticity_Diagram_CIE1960UCS.png')
    plot_chromaticity_diagram_CIE1960UCS(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Chromaticity_Diagram_CIE1976UCS.png')
    plot_chromaticity_diagram_CIE1976UCS(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_SDs_In_Chromaticity_Diagram.png')
    A = colour.ILLUMINANTS_SDS['A']
    D65 = colour.ILLUMINANTS_SDS['D65']
    plot_sds_in_chromaticity_diagram([A, D65], **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_SDs_In_Chromaticity_Diagram_CIE1931.png')
    plot_sds_in_chromaticity_diagram_CIE1931([A, D65], **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_SDs_In_Chromaticity_Diagram_CIE1960UCS.png')
    plot_sds_in_chromaticity_diagram_CIE1960UCS([A, D65], **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_SDs_In_Chromaticity_Diagram_CIE1976UCS.png')
    plot_sds_in_chromaticity_diagram_CIE1976UCS([A, D65], **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Pointer_Gamut.png')
    plot_pointer_gamut(**arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_RGB_Colourspaces_In_Chromaticity_Diagram.png')
    plot_RGB_colourspaces_in_chromaticity_diagram(
        ['ITU-R BT.709', 'ACEScg', 'S-Gamut'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_RGB_Colourspaces_In_Chromaticity_Diagram_CIE1931.png')
    plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931(
        ['ITU-R BT.709', 'ACEScg', 'S-Gamut'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Colourspaces_In_'
        'Chromaticity_Diagram_CIE1960UCS.png')
    plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS(
        ['ITU-R BT.709', 'ACEScg', 'S-Gamut'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Colourspaces_In_'
        'Chromaticity_Diagram_CIE1976UCS.png')
    plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS(
        ['ITU-R BT.709', 'ACEScg', 'S-Gamut'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Chromaticities_In_'
        'Chromaticity_Diagram_Plot.png')
    RGB = np.random.random((128, 128, 3))
    plot_RGB_chromaticities_in_chromaticity_diagram(RGB, 'ITU-R BT.709',
                                                    **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Chromaticities_In_'
        'Chromaticity_Diagram_CIE1931.png')
    plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(
        RGB, 'ITU-R BT.709', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Chromaticities_In_'
        'Chromaticity_Diagram_CIE1960UCS.png')
    plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS(
        RGB, 'ITU-R BT.709', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Chromaticities_In_'
        'Chromaticity_Diagram_CIE1976UCS.png')
    plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS(
        RGB, 'ITU-R BT.709', **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Ellipses_MacAdam1942_In_Chromaticity_Diagram.png')
    plot_ellipses_MacAdam1942_in_chromaticity_diagram(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Ellipses_MacAdam1942_In_'
        'Chromaticity_Diagram_CIE1931.png')
    plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Ellipses_MacAdam1942_In_'
        'Chromaticity_Diagram_CIE1960UCS.png')
    plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Ellipses_MacAdam1942_In_'
        'Chromaticity_Diagram_CIE1976UCS.png')
    plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS(**arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Single_CCTF.png')
    plot_single_cctf('ITU-R BT.709', **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Multi_CCTFs.png')
    plot_multi_cctfs(['ITU-R BT.709', 'sRGB'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_Munsell_Value_Function.png')
    plot_single_munsell_value_function('ASTM D1535-08', **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Multi_Munsell_Value_Functions.png')
    plot_multi_munsell_value_functions(['ASTM D1535-08', 'McCamy 1987'],
                                       **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Single_SD_Rayleigh_Scattering.png')
    plot_single_sd_rayleigh_scattering(**arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_The_Blue_Sky.png')
    plot_the_blue_sky(**arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_Colour_Quality_Bars.png')
    illuminant = colour.ILLUMINANTS_SDS['FL2']
    light_source = colour.LIGHT_SOURCES_SDS['Kinoton 75P']
    light_source = light_source.copy().align(colour.SpectralShape(360, 830, 1))
    cqs_i = colour.colour_quality_scale(illuminant, additional_data=True)
    cqs_l = colour.colour_quality_scale(light_source, additional_data=True)
    plot_colour_quality_bars([cqs_i, cqs_l], **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Single_SD_Colour_Rendering_Index_Bars.png')
    illuminant = colour.ILLUMINANTS_SDS['FL2']
    plot_single_sd_colour_rendering_index_bars(illuminant, **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Multi_SDs_Colour_Rendering_Indexes_Bars.png')
    light_source = colour.LIGHT_SOURCES_SDS['Kinoton 75P']
    plot_multi_sds_colour_rendering_indexes_bars([illuminant, light_source],
                                                 **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Single_SD_Colour_Quality_Scale_Bars.png')
    illuminant = colour.ILLUMINANTS_SDS['FL2']
    plot_single_sd_colour_quality_scale_bars(illuminant, **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Multi_SDs_Colour_Quality_Scales_Bars.png')
    light_source = colour.LIGHT_SOURCES_SDS['Kinoton 75P']
    plot_multi_sds_colour_quality_scales_bars([illuminant, light_source],
                                              **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_Planckian_Locus.png')
    plot_planckian_locus(**arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram.png')
    plot_planckian_locus_in_chromaticity_diagram(['A', 'B', 'C'], **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram_CIE1931.png')
    plot_planckian_locus_in_chromaticity_diagram_CIE1931(['A', 'B', 'C'],
                                                         **arguments)

    arguments['filename'] = os.path.join(
        output_directory,
        'Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram_CIE1960UCS.png')
    plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(['A', 'B', 'C'],
                                                            **arguments)
    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Colourspaces_Gamuts.png')
    plot_RGB_colourspaces_gamuts(['ITU-R BT.709', 'ACEScg', 'S-Gamut'],
                                 **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Plotting_Plot_RGB_Colourspaces_Gamuts.png')
    plot_RGB_colourspaces_gamuts(['ITU-R BT.709', 'ACEScg', 'S-Gamut'],
                                 **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Plotting_Plot_RGB_Scatter.png')
    plot_RGB_scatter(RGB, 'ITU-R BT.709', **arguments)

    # *************************************************************************
    # "tutorial.rst"
    # *************************************************************************
    arguments['filename'] = os.path.join(output_directory,
                                         'Tutorial_Visible_Spectrum.png')
    plot_visible_spectrum(**arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Tutorial_Sample_SD.png')
    sample_sd_data = {
        380: 0.048,
        385: 0.051,
        390: 0.055,
        395: 0.060,
        400: 0.065,
        405: 0.068,
        410: 0.068,
        415: 0.067,
        420: 0.064,
        425: 0.062,
        430: 0.059,
        435: 0.057,
        440: 0.055,
        445: 0.054,
        450: 0.053,
        455: 0.053,
        460: 0.052,
        465: 0.052,
        470: 0.052,
        475: 0.053,
        480: 0.054,
        485: 0.055,
        490: 0.057,
        495: 0.059,
        500: 0.061,
        505: 0.062,
        510: 0.065,
        515: 0.067,
        520: 0.070,
        525: 0.072,
        530: 0.074,
        535: 0.075,
        540: 0.076,
        545: 0.078,
        550: 0.079,
        555: 0.082,
        560: 0.087,
        565: 0.092,
        570: 0.100,
        575: 0.107,
        580: 0.115,
        585: 0.122,
        590: 0.129,
        595: 0.134,
        600: 0.138,
        605: 0.142,
        610: 0.146,
        615: 0.150,
        620: 0.154,
        625: 0.158,
        630: 0.163,
        635: 0.167,
        640: 0.173,
        645: 0.180,
        650: 0.188,
        655: 0.196,
        660: 0.204,
        665: 0.213,
        670: 0.222,
        675: 0.231,
        680: 0.242,
        685: 0.251,
        690: 0.261,
        695: 0.271,
        700: 0.282,
        705: 0.294,
        710: 0.305,
        715: 0.318,
        720: 0.334,
        725: 0.354,
        730: 0.372,
        735: 0.392,
        740: 0.409,
        745: 0.420,
        750: 0.436,
        755: 0.450,
        760: 0.462,
        765: 0.465,
        770: 0.448,
        775: 0.432,
        780: 0.421
    }

    sd = colour.SpectralDistribution(sample_sd_data, name='Sample')
    plot_single_sd(sd, **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Tutorial_SD_Interpolation.png')
    sd_copy = sd.copy()
    sd_copy.interpolate(colour.SpectralShape(400, 770, 1))
    plot_multi_sds(
        [sd, sd_copy], bounding_box=[730, 780, 0.25, 0.5], **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Tutorial_Sample_Swatch.png')
    sd = colour.SpectralDistribution(sample_sd_data)
    cmfs = colour.STANDARD_OBSERVERS_CMFS[
        'CIE 1931 2 Degree Standard Observer']
    illuminant = colour.ILLUMINANTS_SDS['D65']
    with domain_range_scale('1'):
        XYZ = colour.sd_to_XYZ(sd, cmfs, illuminant)
        RGB = colour.XYZ_to_sRGB(XYZ)
    plot_single_colour_swatch(
        ColourSwatch('Sample', RGB),
        text_parameters={'size': 'x-large'},
        **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Tutorial_Neutral5.png')
    patch_name = 'neutral 5 (.70 D)'
    patch_sd = colour.COLOURCHECKERS_SDS['ColorChecker N Ohta'][patch_name]
    with domain_range_scale('1'):
        XYZ = colour.sd_to_XYZ(patch_sd, cmfs, illuminant)
        RGB = colour.XYZ_to_sRGB(XYZ)
    plot_single_colour_swatch(
        ColourSwatch(patch_name.title(), RGB),
        text_parameters={'size': 'x-large'},
        **arguments)

    arguments['filename'] = os.path.join(output_directory,
                                         'Tutorial_Colour_Checker.png')
    plot_single_colour_checker(
        colour_checker='ColorChecker 2005',
        text_parameters={'visible': False},
        **arguments)

    arguments['filename'] = os.path.join(
        output_directory, 'Tutorial_CIE_1931_Chromaticity_Diagram.png')
    xy = colour.XYZ_to_xy(XYZ)
    plot_chromaticity_diagram_CIE1931(standalone=False)
    x, y = xy
    plt.plot(x, y, 'o-', color='white')
    # Annotating the plot.
    plt.annotate(
        patch_sd.name.title(),
        xy=xy,
        xytext=(-50, 30),
        textcoords='offset points',
        arrowprops=dict(arrowstyle='->', connectionstyle='arc3, rad=-0.2'))
    render(
        standalone=True,
        limits=(-0.1, 0.9, -0.1, 0.9),
        x_tighten=True,
        y_tighten=True,
        **arguments)

    # *************************************************************************
    # "basics.rst"
    # *************************************************************************
    arguments['filename'] = os.path.join(output_directory,
                                         'Basics_Logo_Small_001_CIE_XYZ.png')
    RGB = colour.read_image(
        os.path.join(output_directory, 'Logo_Small_001.png'))[..., 0:3]
    XYZ = colour.sRGB_to_XYZ(RGB)
    colour.plotting.plot_image(
        XYZ, text_parameters={'text': 'sRGB to XYZ'}, **arguments)
예제 #23
0
xyY_list_fromtable = [[np.float(x) for x in datum.split()[3:]]
                      for datum in data[1:]]

# adjust for y=0's
for xyY in xyY_list_fromtable:
    if xyY[1] == 0:
        xyY[1] = 1e-50

# Thuis didn't work
#xyY_list = [colour.munsell_colour_to_xyY(HVC) for HVC in Munsell_list]

XYZ_list_fromtable = [colour.xyY_to_XYZ(xyY) for xyY in xyY_list_fromtable]

rgb_list_fromtable = [[
    np.uint8(round(255 * x)) for x in colour.XYZ_to_sRGB(XYZ, C)
] for XYZ in XYZ_list_fromtable]
L = len(rgb_list_fromtable)
Munsell_RGB_lookuptable = [[Munsell_list[i], rgb_list_fromtable[i]]
                           for i in range(L)]

with open('Munsell_RGB_lookuptable.data', 'wb') as MRlt:
    # store the data as binary data stream
    pickle.dump(Munsell_RGB_lookuptable, MRlt)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
xs, ys, zs = [], [], []
for rbg in rgb_list_fromtable:
    xs.append(rbg[0])
    ys.append(rbg[1])
예제 #24
0
import colour
from colour.utilities import message_box

message_box("Automatic Colour Conversion Graph")

message_box(
    'Converting a "ColorChecker" "dark skin" sample spectral distribution to '
    '"Output-Referred" "sRGB" colourspace.'
)

sd_dark_skin = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"]
print(colour.convert(sd_dark_skin, "Spectral Distribution", "sRGB"))
print(
    colour.XYZ_to_sRGB(
        colour.sd_to_XYZ(
            sd_dark_skin, illuminant=colour.SDS_ILLUMINANTS["D65"]
        )
        / 100
    )
)

print("\n")

RGB = np.array([0.45675795, 0.30986982, 0.24861924])
message_box(
    f'Converting to the "CAM16-UCS" colourspace from given "Output-Referred" '
    f'"sRGB" colourspace values:\n\n\t{RGB}'
)
print(colour.convert(RGB, "Output-Referred RGB", "CAM16UCS"))
specification = colour.XYZ_to_CAM16(
    colour.sRGB_to_XYZ(RGB) * 100,
    XYZ_w=colour.xy_to_XYZ(
예제 #25
0
RGB = (1.26651054, 0.91394181, 0.76936593)
message_box(('Converting to "CIE XYZ" tristimulus values from given "RGB" '
             'colourspace values:\n'
             '\n\t{0}'.format(RGB)))
print(
    colour.RGB_to_XYZ(RGB, colour.sRGB_COLOURSPACE.whitepoint, D50,
                      colour.sRGB_COLOURSPACE.RGB_to_XYZ_matrix, 'Bradford',
                      colour.sRGB_COLOURSPACE.decoding_cctf))

print('\n')

message_box(('Converting to "sRGB" colourspace from given "CIE XYZ" '
             'tristimulus values using convenient definition:\n'
             '\n\t{0}'.format(XYZ)))
print(colour.XYZ_to_sRGB(XYZ, D50))

print('\n')

message_box(('Converting to "CIE UCS" colourspace from given "CIE XYZ" '
             'tristimulus values:\n'
             '\n\t{0}'.format(XYZ)))
print(colour.XYZ_to_UCS(XYZ))

print('\n')

UCS = (0.76117564, 1.00000000, 1.17819430)
message_box(('Converting to "CIE XYZ" tristimulus values from given "CIE UCS" '
             'colourspace values:\n'
             '\n\t{0}'.format(UCS)))
print(colour.UCS_to_XYZ(UCS))
예제 #26
0
"""
Showcases reflectance recovery computations using *Mallett et al. (2019)*
method.
"""

import numpy as np

import colour
from colour.utilities import message_box

message_box('"Mallett et al. (2019)" - Reflectance Recovery Computations')

illuminant = colour.SDS_ILLUMINANTS['D65']

XYZ = np.array([0.20654008, 0.12197225, 0.05136952])
RGB = colour.XYZ_to_sRGB(XYZ, apply_cctf_encoding=False)
message_box('Recovering reflectance using "Mallett et al. (2019)" method '
            'from given "XYZ" tristimulus values:\n'
            '\n\tXYZ: {0}'.format(XYZ))
sd = colour.XYZ_to_sd(XYZ, method='Mallett 2019')
print(sd)
print(colour.recovery.RGB_to_sd_Mallett2019(RGB))
print(colour.sd_to_XYZ(sd, illuminant=illuminant) / 100)

print('\n')

message_box('Generating the "Mallett et al. (2019)" basis functions for the '
            '*Pal/Secam* colourspace:')
cmfs = (colour.MSDS_CMFS['CIE 1931 2 Degree Standard Observer'].copy().align(
    colour.SpectralShape(360, 780, 10)))
illuminant = colour.SDS_ILLUMINANTS['D65'].copy().align(cmfs.shape)
예제 #27
0
                        s = black_body_sd[k]
                        #print("s: {}, k: {}".format(s, k))
                        if spetral_f_initial <= k and k <= spetral_f_final:
                            subset_of_blackbody_sd[
                                k] = s * intensity_normalization_factor
                        else:
                            subset_of_blackbody_sd[k] = 0.0
                    subset_of_blackbody_sd = colour.SpectralDistribution(
                        subset_of_blackbody_sd)

                    #Convert our spectrum into a color
                    star_xyz_color = colour.sd_to_XYZ(subset_of_blackbody_sd,
                                                      cmfs)
                    star_rgb_color = [
                        min(max(int(c), 0), 255)
                        for c in colour.XYZ_to_sRGB(star_xyz_color / 100)
                    ]

                    y_position = j * 16 + 1 + y
                    x_position = i * 32 + 1 + x
                    for c in range(3):
                        output_texture[y_position][x_position][
                            c] = star_rgb_color[c]
                    output_texture[y_position][x_position][3] = 255
            progress_bar_status += 1
            bar.update(progress_bar_status)

#Write this into a texture
print("Saving texture...")
imarray = np.asarray(output_texture)
imarray = np.flip(imarray, 0)
예제 #28
0
             '\n\t{0}'.format(RGB)))
print(colour.RGB_to_XYZ(
    RGB,
    colour.sRGB_COLOURSPACE.whitepoint,
    colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50'],
    colour.sRGB_COLOURSPACE.to_XYZ,
    'Bradford',
    colour.sRGB_COLOURSPACE.inverse_transfer_function))

print('\n')

message_box(('Converting to "sRGB" colourspace from given "CIE XYZ" '
             'colourspace values using convenient definition:\n'
             '\n\t{0}'.format(XYZ)))
print(colour.XYZ_to_sRGB(
    XYZ,
    colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50']))

print('\n')

message_box(('Converting to "CIE UCS" colourspace from given "CIE XYZ" '
             'colourspace values:\n'
             '\n\t{0}'.format(XYZ)))
print(colour.XYZ_to_UCS(XYZ))

print('\n')

UCS = [0.76117564, 1., 1.1781943]
message_box(('Converting to "CIE XYZ" colourspace from given "CIE UCS" '
             'colourspace values:\n'
             '\n\t{0}'.format(UCS)))
예제 #29
0
lamL = np.arange(360, 830, 5)
retL = np.arange(.05, 0.3, .0001) * 5
I = np.array([[mlEQ(lam, ret) for lam in lamL] for ret in retL])
XYZ = [
    colour.spectral_to_XYZ(colour.SpectralPowerDistribution(
        {lam: i
         for (lam, i) in zip(lamL, iL)}),
                           illuminant=colour.ILLUMINANTS_RELATIVE_SPDS["D65"])
    for iL in I
]
ilA = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][
    'D65']  #don't really know what this is, but I think I'm using a halogen lamp
M = np.array([[2.04414, -.5649, -0.3447], [-0.9693, 1.8760, 0.0416],
              [0.0134, -0.1184, 1.0154]])
#RGB = [list(colour.XYZ_to_RGB(xyz/100,ilA,ilA,M)) for xyz in XYZ]
sRGB = [list(colour.XYZ_to_sRGB(xyz / 100)) for xyz in XYZ]
#psd = {lam:i for (lam,i) in zip(lamL,I)}
#psd = colour.SpectralPowerDistribution(psd)
#XYZ = colour.spectral_to_XYZ(psd)
#mlChart = np.array([[i for i in RGB] for j in np.arange(0,1000)])
mlChart2 = np.array([[i for i in sRGB] for j in np.arange(0, 200)])
fig10, ax10 = plt.subplots()
ax10.axis('off')
ax10.imshow(mlChart2)
fig10.savefig('mlChart.png')
sys.exit()
#Now, we can calculate a pretty fair michel-levy chart. Now, set it up so that we can find the colour difference in XYZ between the average colour read in from the image

#Now, import voltage data so we can match it up
voltData = pd.read_csv(
    './DC Field PLM/10-11-2018_DCField_FileName_to_VoltsApplied.csv')
예제 #30
0
swatches_normal = []
swatches_VCC = []
swatches_VAC = []

for i in range(len(swatches)):
    VCC = colour.HelmholtzKohlrausch_effect_luminous_Nayatani1997(swatches[i],
                                                                  wp,
                                                                  L_a,
                                                                  method="VCC")
    VAC = colour.HelmholtzKohlrausch_effect_luminous_Nayatani1997(swatches[i],
                                                                  wp,
                                                                  L_a,
                                                                  method="VAC")

    swatches_normal.append(colour.XYZ_to_sRGB(bg_grey))
    swatches_normal.append(colour.XYZ_to_sRGB(swatches_XYZ[i]))

    swatches_VCC.append(colour.XYZ_to_sRGB(bg_grey))
    swatches_VCC.append(colour.XYZ_to_sRGB(swatches_XYZ[i] / VCC))

    swatches_VAC.append(colour.XYZ_to_sRGB(bg_grey * VAC))
    swatches_VAC.append(colour.XYZ_to_sRGB(swatches_XYZ[i]))

colour_style()

message_box("Plotting swatches with the same luminance (Y).\n"
            "The Helmholtz—Kohlrausch effect will be very noticeable.")
plot_multi_colour_swatches(swatches_normal, compare_swatches="stacked")

message_box("Plotting HKE-compensated swatches with VCC method.\n"