コード例 #1
0
ファイル: xrite2016.py プロジェクト: dwtian/colour-datasets
    def load(self):
        """
        Syncs, parses, converts and returns the *X-Rite (2016)*
        *New Color Specifications for ColorChecker SG and Classic Charts*
        dataset content.

        Returns
        -------
        OrderedDict
            *X-Rite (2016)* *New Color Specifications for ColorChecker SG and
            Classic Charts* dataset content.

        Examples
        --------
        >>> from colour_datasets.utilities import suppress_stdout
        >>> dataset = XRite2016DatasetLoader()
        >>> with suppress_stdout():
        ...     dataset.load()
        >>> len(dataset.content.keys())
        4
        """

        super(XRite2016DatasetLoader, self).sync()

        keys = (
            'ColorChecker24 - After November 2014',
            'ColorChecker24 - Before November 2014',
            'ColorCheckerSG - After November 2014',
            'ColorCheckerSG - Before November 2014',
        )
        filenames = (
            'ColorChecker24_After_Nov2014.txt',
            'ColorChecker24_Before_Nov2014.txt',
            'ColorCheckerSG_After_Nov2014.txt',
            'ColorCheckerSG_Before_Nov2014.txt',
        )

        # TODO: Implement support for "CGATS" file format in "Colour":
        # https://github.com/colour-science/colour/issues/354
        illuminant = (
            ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['ICC D50'])

        self._content = OrderedDict()
        for key, filename in zip(keys, filenames):
            directory = os.path.splitext(filename)[0]
            path = os.path.join(self.record.repository, 'dataset', directory,
                                filename)

            with codecs.open(path, encoding='utf-8') as xrite_file:
                samples = []
                is_data = False
                lines = filter(None, (line.strip()
                                      for line in xrite_file.readlines()))
                for line in lines:
                    if line == 'END_DATA':
                        is_data = False

                    if is_data:
                        tokens = line.split()
                        samples.append([
                            tokens[0],
                            [
                                float(value.replace(',', '.'))
                                for value in tokens[1:]
                            ],
                        ])

                    if line == 'BEGIN_DATA':
                        is_data = True

            i, j = (6, 4) if len(samples) == 24 else (14, 10)
            samples = np.array(samples)
            samples = np.transpose(samples.reshape([i, j, 2]), [1, 0, 2])
            keys, values = zip(*samples.reshape([-1, 2]))
            values = XYZ_to_xyY(Lab_to_XYZ(values, illuminant))
            self._content[key] = ColourChecker(key,
                                               OrderedDict(zip(keys, values)),
                                               illuminant)

        return self._content
コード例 #2
0
from colour_analysis.constants import DEFAULT_PLOTTING_ILLUMINANT
from colour_analysis.visuals import Symbol

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2013-2019 - Colour Developers'
__license__ = 'New BSD License - http://opensource.org/licenses/BSD-3-Clause'
__maintainer__ = 'Colour Developers'
__email__ = '*****@*****.**'
__status__ = 'Production'

__all__ = [
    'POINTER_GAMUT_DATA', 'POINTER_GAMUT_BOUNDARIES', 'pointer_gamut_visual',
    'pointer_gamut_boundaries_visual', 'pointer_gamut_hull_visual'
]

POINTER_GAMUT_DATA = Lab_to_XYZ(LCHab_to_Lab(POINTER_GAMUT_DATA),
                                POINTER_GAMUT_ILLUMINANT)
"""
Pointer's Gamut data converted to *CIE XYZ* tristimulus values.

POINTER_GAMUT_DATA : ndarray
"""

POINTER_GAMUT_BOUNDARIES = xy_to_XYZ(POINTER_GAMUT_BOUNDARIES)
"""
Pointer's Gamut boundaries data converted to *CIE XYZ* tristimulus values.

POINTER_GAMUT_BOUNDARIES : ndarray
"""


def pointer_gamut_visual(reference_colourspace='CIE xyY',
コード例 #3
0
IMAGE_CCTF_DECODING : unicode
"""

COLOURSPACE_MODEL = 'CIE xyY'
"""
Analysis colour model.

COLOURSPACE_MODEL : unicode
    **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD', 'CAM16UCS',
    'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS', 'CIE UVW', 'DIN 99',
    'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG', 'IPT', 'JzAzBz', 'OSA UCS',
    'hdr-CIELAB', 'hdr-IPT'}**
"""

DATA_POINTER_GAMUT = Lab_to_XYZ(LCHab_to_Lab(DATA_POINTER_GAMUT_VOLUME),
                                CCS_ILLUMINANT_POINTER_GAMUT)
"""
Pointer's Gamut data converted to *CIE XYZ* tristimulus values.

DATA_POINTER_GAMUT : ndarray
"""

IMAGE_CACHE = SimpleCache(default_timeout=60 * 24 * 7)
"""
Server side cache for images.

IMAGE_CACHE : SimpleCache
"""


def load_image(path, decoding_cctf='sRGB'):