From 44f4a9a4bcad2eb2d44c1be668f45565f0e6669b Mon Sep 17 00:00:00 2001 From: Dariusz Majnert Date: Mon, 17 Jun 2024 20:42:01 +0200 Subject: [PATCH] hcl dialog --- .../{HueDialog.py => HCLDialog.py} | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) rename jezyki-skryptowe/image-editor/{HueDialog.py => HCLDialog.py} (78%) diff --git a/jezyki-skryptowe/image-editor/HueDialog.py b/jezyki-skryptowe/image-editor/HCLDialog.py similarity index 78% rename from jezyki-skryptowe/image-editor/HueDialog.py rename to jezyki-skryptowe/image-editor/HCLDialog.py index 6827036..997edfe 100644 --- a/jezyki-skryptowe/image-editor/HueDialog.py +++ b/jezyki-skryptowe/image-editor/HCLDialog.py @@ -1,5 +1,7 @@ import abc -from ImageProcessingWorker import ImageProcessingWorker +import ImageProcessingWorker + + import numpy as np from PyQt6.QtWidgets import QApplication, QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QWidget, QFileDialog, QSlider, QLineEdit, QDialog @@ -9,10 +11,10 @@ from PyQt6.QtCore import Qt, QPoint, QThread from ImageParameterDialog import ImageParameterDialog -class HueDialog(ImageParameterDialog): +class HCLDialog(ImageParameterDialog): def __init__(self, hsv_image): - super().__init__(hsv_image) - self.setWindowTitle("Hue Correction Dialog") + super().__init__(hsv_image, ImageProcessingWorker.HLSImageProcessingWorker) + self.setWindowTitle("HCL Correction") self.layout = QVBoxLayout() self.hue_slider = QSlider(Qt.Orientation.Horizontal) @@ -39,6 +41,7 @@ class HueDialog(ImageParameterDialog): self.layout.addWidget(self.chroma_slider) self.layout.addWidget(self.label3) self.layout.addWidget(self.lightness_slider) + self.layout.addWidget(self.button_box) self.setLayout(self.layout) @@ -54,15 +57,16 @@ class HueDialog(ImageParameterDialog): def process_image(self,hsv_image, values): hue = values.get('hue', 0.0) / 2 - chroma = values.get('chroma', 0.0) + 1.0 - lightness = values.get('lightness', 0.0) + 1.0 + chroma = values.get('chroma', 0.0) + lightness = values.get('lightness', 0.0) hsv_image[..., 0] = (hsv_image[..., 0] + hue) % 180 - # Adjust chroma (saturation) - hsv_image[..., 1] = np.clip(hsv_image[..., 1] * chroma, 0, 255) + hsv_image[..., 1] += (255 * lightness) + hsv_image[..., 1] = np.clip(hsv_image[..., 1], 0, 255) + + hsv_image[..., 2] += (255 * chroma) + hsv_image[..., 2] = np.clip(hsv_image[..., 2], 0, 255) - # Adjust lightness (value) - hsv_image[..., 2] = np.clip(hsv_image[..., 2] * lightness, 0, 255) return hsv_image \ No newline at end of file