diff --git a/src/main.py b/src/main.py index 1bc7de0..6282e08 100644 --- a/src/main.py +++ b/src/main.py @@ -1,9 +1,10 @@ -import sys from PySide6.QtWidgets import QApplication, QCheckBox, QMainWindow, QRadioButton, QVBoxLayout, QHBoxLayout, QLabel, QFrame, QPushButton, QFileDialog, QWidget, QScrollArea from PySide6.QtGui import Qt from PySide6.QtCore import Qt, QSize, QTimer -import cv2 as cv -import numpy as np + +from cv2 import cvtColor, imdecode, imencode, COLOR_BGR2RGB, IMREAD_UNCHANGED +from numpy import fromfile, uint8 +from sys import argv, exit from transformermanager import TransformerManager from transformer import Transformer @@ -195,8 +196,8 @@ def open_image(self): if str_path: self.img_path = str_path - img_array = cv.imdecode(np.fromfile(str_path, dtype=np.uint8), cv.IMREAD_UNCHANGED) - img_array = cv.cvtColor(img_array, cv.COLOR_BGR2RGB) + img_array = imdecode(fromfile(str_path, dtype=uint8), IMREAD_UNCHANGED) + img_array = cvtColor(img_array, COLOR_BGR2RGB) return img_array def open_first_image(self): @@ -321,8 +322,8 @@ def action_download_current_image(self): if file_dialog.exec(): file_path = file_dialog.selectedFiles()[0] try: - array_to_save = cv.cvtColor(self.pipeline[self.index_current_img].img_array, cv.COLOR_BGR2RGB) - _, im_buf_arr = cv.imencode(".png", array_to_save) + array_to_save = cvtColor(self.pipeline[self.index_current_img].img_array, COLOR_BGR2RGB) + _, im_buf_arr = imencode(".png", array_to_save) im_buf_arr.tofile(file_path) print("Image saved successfully.") except Exception as e: @@ -463,7 +464,7 @@ def update_transformation_parameters_frame(self): if __name__ == '__main__': - app = QApplication(sys.argv) + app = QApplication(argv) window = MainWindow() window.show() - sys.exit(app.exec()) + exit(app.exec()) diff --git a/src/menuwithtext.py b/src/menuwithtext.py index 8500db2..0f7abe1 100644 --- a/src/menuwithtext.py +++ b/src/menuwithtext.py @@ -1,6 +1,4 @@ from PySide6.QtWidgets import QComboBox, QLabel, QFrame, QVBoxLayout -from PySide6.QtCore import Qt -from stepslider import StepSlider MAXIMUM_HEIGHT = 65 diff --git a/src/pipelineitem.py b/src/pipelineitem.py index 750399b..6c483a0 100644 --- a/src/pipelineitem.py +++ b/src/pipelineitem.py @@ -1,5 +1,5 @@ from PySide6.QtGui import QPixmap, QImage, qRgb -import numpy as np +from numpy import uint8, require class PipelineItem(): """Object that contains the image in an array and the corresponding transformation item""" @@ -20,8 +20,8 @@ def to_q_image(self, im, copy=False): if im is None: return QImage() - if im.dtype == np.uint8: - im = np.require(im, np.uint8, 'C') + if im.dtype == uint8: + im = require(im, uint8, 'C') if len(im.shape) == 2: qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_Indexed8) qim.setColorTable(gray_color_table) diff --git a/src/sliderwithtext.py b/src/sliderwithtext.py index 98c818f..edfe35e 100644 --- a/src/sliderwithtext.py +++ b/src/sliderwithtext.py @@ -1,5 +1,4 @@ -from PySide6.QtWidgets import QSlider, QLabel, QFrame, QVBoxLayout -from PySide6.QtCore import Qt +from PySide6.QtWidgets import QLabel, QFrame, QVBoxLayout from stepslider import StepSlider MAXIMUM_HEIGHT = 65 diff --git a/src/transformermanager.py b/src/transformermanager.py index 6a0b8ba..a2fa1a0 100644 --- a/src/transformermanager.py +++ b/src/transformermanager.py @@ -1,6 +1,5 @@ from pipelineitem import PipelineItem from transformationitem import TransformationItem -from PySide6.QtWidgets import QApplication, QMessageBox class TransformerManager():