40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import numpy as np
|
|
from PyQt6.QtWidgets import QVBoxLayout, QLabel, QSlider
|
|
from PyQt6.QtCore import Qt
|
|
from .ImageParameterDialog import ImageParameterDialog
|
|
import ImageProcessingWorker
|
|
|
|
class SaturationDialog(ImageParameterDialog):
|
|
def __init__(self, image):
|
|
super().__init__(image, ImageProcessingWorker.HSVImageProcessingWorker)
|
|
self.setWindowTitle("Saturation Adjustment")
|
|
self.layout = QVBoxLayout()
|
|
|
|
self.saturation_slider = QSlider(Qt.Orientation.Horizontal)
|
|
self.saturation_slider.setRange(-100, 100)
|
|
|
|
self.label = QLabel("Saturation: 0")
|
|
self.saturation_slider.valueChanged.connect(lambda value: self.update(self.label, value))
|
|
|
|
self.layout.addWidget(self.label)
|
|
self.layout.addWidget(self.saturation_slider)
|
|
self.layout.addWidget(self.button_box)
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
def update(self, label, value):
|
|
label.setText(f"Saturation: {value}")
|
|
self.send_to_process({
|
|
'saturation': self.saturation_slider.value() / 100.0
|
|
})
|
|
|
|
def process_image(self, image, values):
|
|
saturation = values.get('saturation', 0.0)
|
|
|
|
image[..., 1] = np.clip(image[..., 1] * (1 + saturation), 0, 255)
|
|
|
|
return image
|
|
|
|
@classmethod
|
|
def dialog_name(cls):
|
|
return "Saturation" |