def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None, colorModel='HSV'): super().__init__(targetImage=targetImage, axeSize=axeSize, layer=layer, parent=parent) graphicsScene = self.scene() graphicsScene.colorModel = colorModel # hue curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicR = cubic cubic.channel = channelValues.Hue cubic.initFixedPoints() # sat curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicG = cubic cubic.channel = channelValues.Sat cubic.initFixedPoints() # brightness curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicB = cubic cubic.channel = channelValues.Br cubic.initFixedPoints() # init histograms self.updateHists() # set current curve to sat graphicsScene.cubicItem = graphicsScene.cubicG graphicsScene.cubicItem.setVisible(True) # buttons pushButton1 = QPushButton("Reset Current") pushButton1.clicked.connect(self.resetCurve) pushButton2 = QPushButton("Reset All") pushButton2.clicked.connect(self.resetAllCurves) # options options = ['H', 'S', 'B'] self.listWidget1 = optionsWidget(options=options, exclusive=True) self.listWidget1.setGeometry( 0, 0, self.listWidget1.sizeHintForColumn(0) + 5, self.listWidget1.sizeHintForRow(0) * len(options) + 5) # selection changed handler curves = [ graphicsScene.cubicR, graphicsScene.cubicG, graphicsScene.cubicB ] curveDict = dict(zip(options, curves)) def onSelect1(item): self.scene().cubicItem.setVisible(False) self.scene().cubicItem = curveDict[item.text()] self.scene().cubicItem.setVisible(True) # draw histogram self.scene().invalidate( QRectF(0.0, -self.scene().axeSize, self.scene().axeSize, self.scene().axeSize), QGraphicsScene.BackgroundLayer) self.listWidget1.onSelect = onSelect1 # set initial selection to Saturation item = self.listWidget1.items[options[1]] item.setCheckState(Qt.Checked) self.listWidget1.select(item) # layout gl = QGridLayout() gl.addWidget(self.listWidget1, 0, 0, 2, 1) for i, button in enumerate([pushButton1, pushButton2]): gl.addWidget(button, i, 1) self.addCommandLayout(gl) self.setWhatsThis("""<b>HSV curves</b><br>""" + self.whatsThis()) def f(): layer = graphicsScene.layer layer.applyToStack() layer.parentImage.onImageChanged() self.scene().cubicR.curveChanged.sig.connect(f) self.scene().cubicG.curveChanged.sig.connect(f) self.scene().cubicB.curveChanged.sig.connect(f)
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None, mainForm=None): super().__init__(targetImage=targetImage, axeSize=axeSize, layer=layer, parent=parent, mainForm=mainForm) graphicsScene = self.scene() ######### # L curve ######### cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicR = cubic cubic.channel = channelValues.L # get histogram as a Qimage cubic.histImg = graphicsScene.layer.inputImg().histogram(size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, range=(0, 1), chans=channelValues.L, mode='Lab') # L curve use the default axes cubic.axes = graphicsScene.defaultAxes cubic.initFixedPoints() cubic.axes.setVisible(False) cubic.setVisible(False) ########## # a curve (Green--> Magenta axis) ######### cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicG = cubic cubic.channel = channelValues.a cubic.histImg = graphicsScene.layer.inputImg().histogram(size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, range=(-100, 100), chans=channelValues.a, mode='Lab') # add specific axes gradient = QRadialGradient() gradient.setCenter(QPoint(0, 1)) gradient.setRadius(axeSize*1.4) gradient.setColorAt(0.0, Qt.green) gradient.setColorAt(1.0, Qt.magenta) cubic.axes = self.drawPlotGrid(axeSize, gradient) graphicsScene.addItem(cubic.axes) cubic.initFixedPoints() cubic.axes.setVisible(False) cubic.setVisible(False) # b curve (Blue-->Yellow axis) cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicB = cubic cubic.channel = channelValues.b cubic.histImg = graphicsScene.layer.inputImg().histogram(size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, range=(-100, 100), chans=channelValues.b, mode='Lab') # add specific axes gradient.setColorAt(0.0, Qt.blue) gradient.setColorAt(1.0, Qt.yellow) cubic.axes = self.drawPlotGrid(axeSize, gradient) graphicsScene.addItem(cubic.axes) cubic.initFixedPoints() cubic.axes.setVisible(False) cubic.setVisible(False) # set current to L curve and axes graphicsScene.cubicItem = graphicsScene.cubicR graphicsScene.cubicItem.setVisible(True) graphicsScene.cubicItem.axes.setVisible(True) # buttons pushButton1 = QPushButton("Reset Current") pushButton1.move(100, 20) pushButton1.adjustSize() pushButton1.clicked.connect(self.resetCurve) graphicsScene.addWidget(pushButton1) pushButton2 = QPushButton("Reset All") pushButton2.move(100, 50) pushButton2.adjustSize() pushButton2.clicked.connect(self.resetAllCurves) graphicsScene.addWidget(pushButton2) # options options = ['L', 'a', 'b'] self.listWidget1 = optionsWidget(options=options, exclusive=True) self.listWidget1.setGeometry(0, 10, self.listWidget1.sizeHintForColumn(0) + 5, self.listWidget1.sizeHintForRow(0) * len(options) + 5) graphicsScene.addWidget(self.listWidget1) # selection changed handler curves = [graphicsScene.cubicR, graphicsScene.cubicG, graphicsScene.cubicB] curveDict = dict(zip(options, curves)) def onSelect1(item): cubicItem = self.scene().cubicItem cubicItem.setVisible(False) cubicItem.axes.setVisible(False) self.scene().cubicItem = curveDict[item.text()] self.scene().cubicItem.setVisible(True) self.scene().cubicItem.axes.setVisible(True) # Force to redraw histogram self.scene().invalidate(QRectF(0.0, -self.scene().axeSize, self.scene().axeSize, self.scene().axeSize), QGraphicsScene.BackgroundLayer) self.listWidget1.onSelect = onSelect1 # set initial selection to L item = self.listWidget1.items[options[0]] item.setCheckState(Qt.Checked) self.listWidget1.select(item) self.setWhatsThis("""<b>Lab curves</b><br>""" + self.whatsThis()) def f(): l = graphicsScene.layer l.applyToStack() l.parentImage.onImageChanged() self.scene().cubicR.curveChanged.sig.connect(f) self.scene().cubicG.curveChanged.sig.connect(f) self.scene().cubicB.curveChanged.sig.connect(f)
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None, mainForm=None): super().__init__(targetImage=targetImage, axeSize=axeSize, layer=layer, parent=parent, mainForm=mainForm) # Brightness curve cubic = activeCubicSpline(axeSize) graphicsScene = self.scene() graphicsScene.addItem(cubic) graphicsScene.cubicRGB = cubic cubic.channel = channelValues.RGB cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=[], mode='Luminosity') cubic.initFixedPoints() # Red curve cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicR = cubic cubic.channel = channelValues.Red cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=channelValues.Red) cubic.initFixedPoints() # Green curve cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicG = cubic cubic.channel = channelValues.Green cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=channelValues.Green) cubic.initFixedPoints() # Blue curve cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicB = cubic cubic.channel = channelValues.Blue cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=channelValues.Blue) cubic.initFixedPoints() # set current curve to brightness graphicsScene.cubicItem = graphicsScene.cubicRGB graphicsScene.cubicItem.setVisible(True) # buttons pushButton1 = QbLUePushButton("Reset Current") pushButton1.move(100, 20) pushButton1.adjustSize() pushButton1.clicked.connect(self.resetCurve) graphicsScene.addWidget(pushButton1) pushButton2 = QbLUePushButton("Reset R,G,B") pushButton2.move(100, 50) pushButton2.adjustSize() pushButton2.clicked.connect(self.resetAllCurves) graphicsScene.addWidget(pushButton2) # options options = ['RGB', 'Red', 'Green', 'Blue'] self.listWidget1 = optionsWidget(options=options, exclusive=True) self.listWidget1.setGeometry( 0, 10, self.listWidget1.sizeHintForColumn(0) + 5, self.listWidget1.sizeHintForRow(0) * len(options) + 5) graphicsScene.addWidget(self.listWidget1) # selection changed handler curves = [ graphicsScene.cubicRGB, graphicsScene.cubicR, graphicsScene.cubicG, graphicsScene.cubicB ] curveDict = dict(zip(options, curves)) def onSelect1(item): self.scene().cubicItem.setVisible(False) self.scene().cubicItem = curveDict[item.text()] pushButton2.setEnabled(item.text() != 'RGB') self.scene().cubicItem.setVisible(True) l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged() # Force redraw histogram self.scene().invalidate( QRectF(0.0, -self.scene().axeSize, self.scene().axeSize, self.scene().axeSize), QGraphicsScene.BackgroundLayer) self.listWidget1.onSelect = onSelect1 # set initial selection to RGB item = self.listWidget1.items[options[0]] item.setCheckState(Qt.Checked) self.listWidget1.select(item) self.setWhatsThis("""<b>RGB curves</b><br>""" + self.whatsThis()) def f(): l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged() self.scene().cubicRGB.curveChanged.sig.connect(f) self.scene().cubicR.curveChanged.sig.connect(f) self.scene().cubicG.curveChanged.sig.connect(f) self.scene().cubicB.curveChanged.sig.connect(f)
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None): super().__init__(targetImage=targetImage, axeSize=axeSize, layer=layer, parent=parent) # Brightness curve cubic = activeCubicSpline(axeSize) graphicsScene = self.scene() graphicsScene.addItem(cubic) graphicsScene.cubicRGB = cubic cubic.channel = channelValues.RGB cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=[], mode='Luminosity') cubic.initFixedPoints() # Red curve cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicR = cubic cubic.channel = channelValues.Red cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=channelValues.Red) cubic.initFixedPoints() # Green curve cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicG = cubic cubic.channel = channelValues.Green cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=channelValues.Green) cubic.initFixedPoints() # Blue curve cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicB = cubic cubic.channel = channelValues.Blue cubic.histImg = self.scene().layer.inputImg().histogram( size=graphicsScene.axeSize, bgColor=graphicsScene.bgColor, chans=channelValues.Blue) cubic.initFixedPoints() # set current curve to brightness graphicsScene.cubicItem = graphicsScene.cubicRGB graphicsScene.cubicItem.setVisible(True) # buttons pushButton1 = QbLUePushButton("Reset Current") pushButton1.clicked.connect(self.resetCurve) pushButton2 = QbLUePushButton("Reset R,G,B") pushButton2.clicked.connect(self.resetAllCurves) # options options1 = ['RGB', 'Red', 'Green', 'Blue'] self.listWidget1 = optionsWidget(options=options1) """ self.listWidget1.setGeometry(0, 0, self.listWidget1.sizeHintForColumn(0) + 5, self.listWidget1.sizeHintForRow(0)*len(options1) + 5) """ options2 = ['Luminosity'] self.listWidget2 = optionsWidget(options=options2, exclusive=False) self.graphicsScene.options = UDict( (self.listWidget1.options, self.listWidget2.options)) # selection changed handler curves = [ graphicsScene.cubicRGB, graphicsScene.cubicR, graphicsScene.cubicG, graphicsScene.cubicB ] curveDict = dict(zip(options1, curves)) def onSelect1(item): self.scene().cubicItem.setVisible(False) self.scene().cubicItem = curveDict[item.text()] pushButton2.setEnabled(item.text() != 'RGB') self.scene().cubicItem.setVisible(True) l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged() # Force redraw histogram self.scene().invalidate( QRectF(0.0, -self.scene().axeSize, self.scene().axeSize, self.scene().axeSize), QGraphicsScene.BackgroundLayer) self.listWidget1.onSelect = onSelect1 def onSelect2(item): itemRGB = self.listWidget1.items[options1[0]] if item.isChecked(): if itemRGB.isChecked(): self.listWidget1.unCheckAll() self.listWidget1.checkOption(self.listWidget1.intNames[1]) itemRGB.setFlags(itemRGB.flags() & ~Qt.ItemIsEnabled) else: itemRGB.setFlags(itemRGB.flags() | Qt.ItemIsEnabled) l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged() self.listWidget2.onSelect = onSelect2 # set initial selection to RGB item = self.listWidget1.items[options1[0]] item.setCheckState(Qt.Checked) self.listWidget1.select(item) # layout gl = QGridLayout() container = self.addCommandLayout(gl) gl.addWidget(self.listWidget1, 0, 0, 2, 1) gl.addWidget(self.listWidget2, 0, 1) for i, button in enumerate([pushButton1, pushButton2]): gl.addWidget(button, i, 2) self.adjustSize() self.setViewportMargins(0, 0, 0, container.height() + 15) self.setWhatsThis("""<b>RGB curves</b><br>""" + self.whatsThis()) def f(): l = self.scene().layer l.applyToStack() l.parentImage.onImageChanged() self.scene().cubicRGB.curveChanged.sig.connect(f) self.scene().cubicR.curveChanged.sig.connect(f) self.scene().cubicG.curveChanged.sig.connect(f) self.scene().cubicB.curveChanged.sig.connect(f)
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None, colorModel='HSV', mainForm=None): super().__init__(targetImage=targetImage, axeSize=axeSize, layer=layer, parent=parent, mainForm=mainForm) graphicsScene = self.scene() graphicsScene.colorModel = colorModel # hue curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicR = cubic cubic.channel = channelValues.Hue """ cubic.histImg = graphicsScene.layer.histogram(size=axeSize, bgColor=graphicsScene.bgColor, range=(0, 360), chans=channelValues.Hue, mode='HSpB') """ cubic.initFixedPoints() # sat curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicG = cubic cubic.channel = channelValues.Sat """ cubic.histImg = graphicsScene.layer.histogram(size=axeSize, bgColor=graphicsScene.bgColor, range=(0,1), chans=channelValues.Sat, mode='HSpB') """ cubic.initFixedPoints() # brightness curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicB = cubic cubic.channel = channelValues.Br """ cubic.histImg = graphicsScene.layer.histogram(size=axeSize, bgColor=graphicsScene.bgColor, range=(0,1), chans=channelValues.Br, mode='HSpB') """ cubic.initFixedPoints() # init histograms self.updateHists() # set current curve to sat graphicsScene.cubicItem = graphicsScene.cubicG graphicsScene.cubicItem.setVisible(True) # buttons pushButton1 = QPushButton("Reset Current") pushButton1.move(100, 20) pushButton1.adjustSize() pushButton1.clicked.connect(self.resetCurve) graphicsScene.addWidget(pushButton1) pushButton2 = QPushButton("Reset All") pushButton2.move(100, 50) pushButton2.adjustSize() pushButton2.clicked.connect(self.resetAllCurves) graphicsScene.addWidget(pushButton2) # options options = ['H', 'S', 'B'] self.listWidget1 = optionsWidget(options=options, exclusive=True) self.listWidget1.setGeometry( 0, 10, self.listWidget1.sizeHintForColumn(0) + 5, self.listWidget1.sizeHintForRow(0) * len(options) + 5) graphicsScene.addWidget(self.listWidget1) # selection changed handler curves = [ graphicsScene.cubicR, graphicsScene.cubicG, graphicsScene.cubicB ] curveDict = dict(zip(options, curves)) def onSelect1(item): self.scene().cubicItem.setVisible(False) self.scene().cubicItem = curveDict[item.text()] self.scene().cubicItem.setVisible(True) # draw histogram self.scene().invalidate( QRectF(0.0, -self.scene().axeSize, self.scene().axeSize, self.scene().axeSize), QGraphicsScene.BackgroundLayer) self.listWidget1.onSelect = onSelect1 # set initial selection to Saturation item = self.listWidget1.items[options[1]] item.setCheckState(Qt.Checked) self.listWidget1.select(item) self.setWhatsThis("""<b>HSV curves</b><br>""" + self.whatsThis()) def f(): layer = graphicsScene.layer layer.applyToStack() layer.parentImage.onImageChanged() self.scene().cubicR.curveChanged.sig.connect(f) self.scene().cubicG.curveChanged.sig.connect(f) self.scene().cubicB.curveChanged.sig.connect(f)