def setBlackPoint(self, r, g, b): """ Sets the L curve @param r: @type r: @param g: @type g: @param b: @type b: """ l = self.scene().layer if not l.isActiveLayer(): return sc = self.scene() tmp = np.zeros((1, 1, 3), dtype=np.uint8) tmp[0, 0, :] = (r, g, b) L, a, b = sRGB2LabVec(tmp)[0, 0, :] cubicL = sc.cubicR scale = cubicL.size bPoint = L * scale # don't set black point to white ! if bPoint >= cubicL.size: bPoint -= 10.0 fp = cubicL.fixedPoints # find current white point wPoint = cubicL.size tmp = [p.x() for p in fp if p.y() == -cubicL.size] if tmp: wPoint = min(tmp) # remove control points at the left of wPoint, but the first for p in list(fp[1:-1]): if p.x() < wPoint: fp.remove(p) sc.removeItem(p) # add new black point if needed if bPoint > 0.0 : a = activeSplinePoint(bPoint, 0.0, parentItem=cubicL) fp.append(a) fp.sort(key=lambda z: z.scenePos().x()) cubicL.updatePath() cubicL.updateLUTXY() l.applyToStack() l.parentImage.onImageChanged()
def setWhitePoint(self, r, g, b): """ @param r: @type r: @param g: @type g: @param b: @type b: """ sc = self.scene() cubicRGB, cubicR, cubicG, cubicB = sc.cubicRGB, sc.cubicR, sc.cubicG, sc.cubicB for i, cubic in enumerate([cubicRGB, cubicR, cubicG, cubicB]): scale = cubic.size / 255.0 fp = cubic.fixedPoints wPoint = max(r, g, b) if i == 0 else r if i == 1 else g if i == 2 else b # don't set white point to black! if wPoint <= 10: wPoint += 10.0 # find black point bPoint = 0.0 tmp = [p.x() for p in fp if p.y() == 0.0] if tmp: bPoint = max(tmp) # remove control points at the right of bPoint for p in list(fp[1:-1]): if p.x() > bPoint: cubic.fixedPoints.remove(p) sc.removeItem(p) # add new white point if needed if wPoint < cubic.size: p = activeSplinePoint(wPoint * scale, -cubic.size, parentItem=cubic) cubic.fixedPoints.append(p) cubic.fixedPoints.sort(key=lambda z: z.scenePos().x()) cubic.updatePath() cubic.updateLUTXY() l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged()
def setBlackPoint(self, r, g, b): """ @param r: @type r: @param g: @type g: @param b: @type b: """ sc = self.scene() bPoint = min(r, g, b) # don't set black point to white ! if bPoint >= 255: bPoint -= 10.0 cubicRGB, cubicR, cubicG, cubicB = sc.cubicRGB, sc.cubicR, sc.cubicG, sc.cubicB for cubic in [cubicRGB, cubicR, cubicG, cubicB]: scale = cubic.size / 255.0 fp = cubic.fixedPoints # find current white point wPoint = cubic.size tmp = [p.x() for p in fp if p.y() == -cubic.size] if tmp: wPoint = min(tmp) # remove control points at the left of wPoint, but the first for p in list(fp[1:-1]): if p.x() < wPoint: fp.remove(p) sc.removeItem(p) # add new black point if needed if bPoint > 0.0: a = activeSplinePoint(bPoint * scale, 0.0, parentItem=cubic) cubic.fixedPoints.append(a) cubic.fixedPoints.sort(key=lambda z: z.scenePos().x()) cubic.updatePath() cubic.updateLUTXY() l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged()
def setWhitePoint(self, r, g, b, luminance=True, balance=True): """ for a, b curves, the method sets first and @param r: @type r: @param g: @type g: @param b: @type b: @param luminance: @type luminance: @param balance: @type balance """ l = self.scene().layer if not l.isActiveLayer(): return sc = self.scene() tmp = np.zeros((1, 1, 3,), dtype=np.uint8) tmp[0, 0, :] = (r, g, b) L, a, b = sRGB2LabVec(tmp)[0, 0, :] cubicL, cubica, cubicb = sc.cubicR, sc.cubicG, sc.cubicB if luminance: ########## # L curve ########## cubic = cubicL scale = cubic.size fp = cubic.fixedPoints wPoint = L * scale # don't set white point to black! if wPoint <= 10: wPoint += 10.0 # find black point bPoint = 0.0 tmp = [p.x() for p in fp if p.y() == 0.0] if tmp: bPoint = max(tmp) # remove control points at the right of bPoint for p in list(fp[1:-1]): if p.x() > bPoint: cubic.fixedPoints.remove(p) sc.removeItem(p) # add new white point if needed if wPoint < cubic.size: p = activeSplinePoint(wPoint, -cubic.size, parentItem=cubic) cubic.fixedPoints.append(p) cubic.fixedPoints.sort(key=lambda z: z.scenePos().x()) cubic.updatePath() cubic.updateLUTXY() if balance: ############# # a, b curves ############# corr = cubicL.size/8 for i, cubic in enumerate([cubica, cubicb]): fp = cubic.fixedPoints scale = cubic.size / (127 * 2.0) wPoint = a * scale if i==0 else b * scale # remove all control points but the first and the last for p in list(fp[1:-1]): fp.remove(p) sc.removeItem(p) # according to the sign of wPoint, shift horizontally # first or last control point by 2*wPoint wPoint *= 2.0 p = cubic.fixedPoints[0] p.setPos(max(0, wPoint) + corr, 0) p = cubic.fixedPoints[-1] p.setPos(min(cubic.size, cubic.size + wPoint) - corr, -cubic.size) cubic.updatePath() cubic.updateLUTXY() l.applyToStack() l.parentImage.onImageChanged()