Example #1
0
class BezierCMapModel(object):
    def __init__(self, bezier_model, min_JK, max_JK):
        self.bezier_model = bezier_model
        self.min_JK = min_JK
        self.max_JK = max_JK
        self.trigger = Trigger()

        self.bezier_model.trigger.add_callback(self.trigger.fire)

    def set_JK_minmax(self, min_JK, max_JK):
        self.min_JK = min_JK
        self.max_JK = max_JK
        self.trigger.fire()

    def get_JKapbp_at(self, at):
        ap, bp = self.bezier_model.get_bezier_points_at(at)
        JK = (self.max_JK - self.min_JK) * at + self.min_JK
        return JK, ap, bp

    def get_JKapbp(self, num=200):
        # ap, bp = self.bezier_model.get_bezier_points(num)
        # assert ap.ndim == bp.ndim == 1
        # JK = np.linspace(self.min_JK, self.max_JK, num=ap.shape[0])
        # return JK, ap, bp
        return self.get_JKapbp_at(np.linspace(0, 1, num))

    def get_sRGB(self, num=200):
        # Return sRGB and out-of-gamut mask
        JK, ap, bp = self.get_JKapbp(num=num)
        JMh = _JKapbp_to_JMh(np.column_stack((JK, ap, bp)))
        sRGB = _JMh_to_sRGB(JMh)
        oog = np.any((sRGB > 1) | (sRGB < 0), axis=-1)
        sRGB[oog, :] = np.nan
        return sRGB, oog
Example #2
0
class BezierCMapModel(object):
    def __init__(self, bezier_model, min_Jp, max_Jp):
        self.bezier_model = bezier_model
        self.min_Jp = min_Jp
        self.max_Jp = max_Jp
        self.trigger = Trigger()

        self.bezier_model.trigger.add_callback(self.trigger.fire)

    def set_Jp_minmax(self, min_Jp, max_Jp):
        self.min_Jp = min_Jp
        self.max_Jp = max_Jp
        self.trigger.fire()

    def get_Jpapbp_at(self, at):
        ap, bp = self.bezier_model.get_bezier_points_at(at)
        Jp = (self.max_Jp - self.min_Jp) * at + self.min_Jp
        return Jp, ap, bp

    def get_Jpapbp(self, num=200):
        return self.get_Jpapbp_at(np.linspace(0, 1, num))

    def get_sRGB(self, num=200):
        # Return sRGB and out-of-gamut mask
        Jp, ap, bp = self.get_Jpapbp(num=num)
        sRGB = _uniform_to_sRGB1(np.column_stack((Jp, ap, bp)))
        oog = np.any((sRGB > 1) | (sRGB < 0), axis=-1)
        sRGB[oog, :] = np.nan
        return sRGB, oog
Example #3
0
class BezierCMapModel(object):
    def __init__(self, bezier_model, min_Jp, max_Jp):
        self.bezier_model = bezier_model
        self.min_Jp = min_Jp
        self.max_Jp = max_Jp
        self.trigger = Trigger()

        self.bezier_model.trigger.add_callback(self.trigger.fire)

    def set_Jp_minmax(self, min_Jp, max_Jp):
        self.min_Jp = min_Jp
        self.max_Jp = max_Jp
        self.trigger.fire()

    def get_Jpapbp_at(self, at):
        ap, bp = self.bezier_model.get_bezier_points_at(at)
        Jp = (self.max_Jp - self.min_Jp) * at + self.min_Jp
        return Jp, ap, bp

    def get_Jpapbp(self, num=200):
        return self.get_Jpapbp_at(np.linspace(0, 1, num))

    def get_sRGB(self, num=200):
        # Return sRGB and out-of-gamut mask
        Jp, ap, bp = self.get_Jpapbp(num=num)
        sRGB = _uniform_to_sRGB1(np.column_stack((Jp, ap, bp)))
        oog = np.any((sRGB > 1) | (sRGB < 0), axis=-1)
        sRGB[oog, :] = np.nan
        return sRGB, oog
Example #4
0
class HighlightPointModel(object):
    def __init__(self, cmap_model, point):
        self._cmap_model = cmap_model
        self._point = point
        self.trigger = Trigger()

        self._cmap_model.trigger.add_callback(self.trigger.fire)

    def get_point(self):
        return self._point

    def set_point(self, point):
        self._point = point
        self.trigger.fire()

    def get_JKapbp(self):
        return self._cmap_model.get_JKapbp_at(self._point)
Example #5
0
class HighlightPointModel(object):
    def __init__(self, cmap_model, point):
        self._cmap_model = cmap_model
        self._point = point
        self.trigger = Trigger()

        self._cmap_model.trigger.add_callback(self.trigger.fire)

    def get_point(self):
        return self._point

    def set_point(self, point):
        self._point = point
        self.trigger.fire()

    def get_Jpapbp(self):
        return self._cmap_model.get_Jpapbp_at(self._point)