Пример #1
0
    def __init__(
        self,
        sds,
        shape,
        cmfs=STANDARD_OBSERVER_CMFS['CIE 1931 2 Degree Standard Observer'],
        illuminant=sd_ones()):
        """
        Parameters
        ----------
        sds : ndarray (n,m)
            Reflectances of the ``n`` reference colours to be used for
            optimisation.
        shape : SpectralShape
            Spectral shape of ``sds``.
        cmfs : XYZ_ColourMatchingFunctions, optional
            Standard observer colour matching functions.
        illuminant : SpectralDistribution, optional
            Illuminant spectral distribution.
        """

        self.shape = shape
        self.wl = shape.range()
        self.dw = self.wl[1] - self.wl[0]
        self.cmfs = cmfs.copy().align(shape)
        self.illuminant = illuminant.copy().align(shape)
        self.xy_w = XYZ_to_xy(sd_to_XYZ(illuminant, cmfs=cmfs))

        # The normalising constant used in sd_to_XYZ.
        self.k = 1 / (np.sum(self.cmfs.values[:, 1] * self.illuminant.values) *
                      self.dw)

        # Python 3: super().__init__(...)
        super(Otsu2018Tree, self).__init__(self, Colours(self, sds))
Пример #2
0
message_box('Sample spectral distribution interpolation.')
sd_clone.interpolate(colour.SpectralShape(360, 780, 1))
print(sd_clone[666])

print('\n')

message_box('Sample spectral distribution extrapolation.')
sd_clone.extrapolate(colour.SpectralShape(340, 830))
print(sd_clone[340], sd_clone[360])

print('\n')

message_box('Sample spectral distribution align.')
sd_clone.align(colour.SpectralShape(400, 700, 5))
print(sd_clone[400], sd_clone[700])

print('\n')

message_box('Constant value filled spectral distribution.')
print(colour.sd_constant(3.1415)[400])

print('\n')

message_box('Zeros filled spectral distribution.')
print(colour.sd_zeros()[400])

print('\n')

message_box('Ones filled spectral distribution.')
print(colour.sd_ones()[400])
Пример #3
0
message_box('Sample spectral distribution interpolation.')
clone_sd.interpolate(colour.SpectralShape(360, 780, 1))
print(clone_sd[666])

print('\n')

message_box('Sample spectral distribution extrapolation.')
clone_sd.extrapolate(colour.SpectralShape(340, 830))
print(clone_sd[340], clone_sd[360])

print('\n')

message_box('Sample spectral distribution align.')
clone_sd.align(colour.SpectralShape(400, 700, 5))
print(clone_sd[400], clone_sd[700])

print('\n')

message_box('Constant value filled spectral distribution.')
print(colour.sd_constant(3.1415)[400])

print('\n')

message_box('Zeros filled spectral distribution.')
print(colour.sd_zeros()[400])

print('\n')

message_box('Ones filled spectral distribution.')
print(colour.sd_ones()[400])