How to use the colorio._linalg.solve function in colorio

To help you get started, we’ve selected a few colorio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / colorio / colorio / _jzazbz.py View on Github external
def to_xyz100(self, jzazbz):
        jz, az, bz = jzazbz
        iz = (jz + self.d0) / (1 + self.d - self.d * (jz + self.d0))
        lms_ = solve(self.M2, numpy.array([iz, az, bz]))
        assert numpy.all(lms_ >= 0.0)
        lms = 10000 * (
            (self.c1 - lms_ ** (1 / self.p))
            / (self.c3 * lms_ ** (1 / self.p) - self.c2)
        ) ** (1 / self.n)
        x_, y_, z_ = solve(self.M1, lms)
        x = (x_ + (self.b - 1) * z_) / self.b
        y = (y_ + (self.g - 1) * x) / self.g
        # return (numpy.array([x, y, z_]).T * self.whitepoint).T
        return numpy.array([x, y, z_])
github nschloe / colorio / colorio / _rlab.py View on Github external
def to_xyz100(self, lab):
        L_R, a_R, b_R = lab

        y_ref_s = L_R / 100
        x_ref_s = a_R / 430 + y_ref_s
        z_ref_s = y_ref_s - b_R / 170

        xyz_ref = numpy.array([x_ref_s, y_ref_s, z_ref_s]) ** (1.0 / self.sigma)
        return solve(self.M, (solve(self.R, xyz_ref).T / self.a_lms).T)
github nschloe / colorio / colorio / _ictcp.py View on Github external
def to_rec2100(self, ictcp):
        lms_ = solve(self.M2, ictcp)

        t = lms_ ** (1 / self.m2) - self.c1
        # This next line is part of the model, but really it shouldn't occur for sane
        # input data.
        # t[t < 0] = 0.0
        lms = (t / (self.c2 - self.c3 * lms_ ** (1 / self.m2))) ** (1 / self.m1)

        rgb = solve(self.M1, lms)
        return rgb
github nschloe / colorio / colorio / _hdr.py View on Github external
def from_xyz100(self, xyz100):
        # TODO NaN the values smaller than 0 and larger than 1
        return solve(self.invM, xyz100 / 100)
github nschloe / colorio / colorio / _ipt.py View on Github external
def to_xyz100(self, ipt):
        lms_ = solve(self.M2, ipt)
        lms = numpy.sign(lms_) * numpy.abs(lms_) ** (1 / 0.43)
        xyz = solve(self.M1, lms)
        return xyz
github nschloe / colorio / colorio / _srgb.py View on Github external
def from_xyz100(self, xyz):
        # https://en.wikipedia.org/wiki/SRGB#The_forward_transformation_(CIE_XYZ_to_sRGB)
        # http://www.color.org/srgb.pdf
        # TODO NaN the values smaller than 0 and larger than 1
        return solve(self.invM, xyz / 100)
github nschloe / colorio / colorio / _ipt.py View on Github external
def to_xyz100(self, ipt):
        lms_ = solve(self.M2, ipt)
        lms = numpy.sign(lms_) * numpy.abs(lms_) ** (1 / 0.43)
        xyz = solve(self.M1, lms)
        return xyz
github nschloe / colorio / colorio / _jzazbz.py View on Github external
def to_xyz100(self, jzazbz):
        jz, az, bz = jzazbz
        iz = (jz + self.d0) / (1 + self.d - self.d * (jz + self.d0))
        lms_ = solve(self.M2, numpy.array([iz, az, bz]))
        assert numpy.all(lms_ >= 0.0)
        lms = 10000 * (
            (self.c1 - lms_ ** (1 / self.p))
            / (self.c3 * lms_ ** (1 / self.p) - self.c2)
        ) ** (1 / self.n)
        x_, y_, z_ = solve(self.M1, lms)
        x = (x_ + (self.b - 1) * z_) / self.b
        y = (y_ + (self.g - 1) * x) / self.g
        # return (numpy.array([x, y, z_]).T * self.whitepoint).T
        return numpy.array([x, y, z_])
github nschloe / colorio / colorio / _ictcp.py View on Github external
def to_rec2100(self, ictcp):
        lms_ = solve(self.M2, ictcp)

        t = lms_ ** (1 / self.m2) - self.c1
        # This next line is part of the model, but really it shouldn't occur for sane
        # input data.
        # t[t < 0] = 0.0
        lms = (t / (self.c2 - self.c3 * lms_ ** (1 / self.m2))) ** (1 / self.m1)

        rgb = solve(self.M1, lms)
        return rgb