| 19 | }""" |
| 20 | |
| 21 | class ImageProcessingGUI(QMainWindow): |
| 22 | |
| 23 | def __init__(self): |
| 24 | super().__init__() |
| 25 | self.initializeUI() |
| 26 | |
| 27 | def initializeUI(self): |
| 28 | """Initialize the window and display its contents to the screen.""" |
| 29 | self.setMinimumSize(900, 600) |
| 30 | self.setWindowTitle('5.1 - Image Processing GUI') |
| 31 | |
| 32 | self.contrast_adjusted = False |
| 33 | self.brightness_adjusted = False |
| 34 | self.image_smoothing_checked = False |
| 35 | self.edge_detection_checked = False |
| 36 | |
| 37 | self.setupWindow() |
| 38 | self.setupMenu() |
| 39 | self.show() |
| 40 | |
| 41 | def setupWindow(self): |
| 42 | """Set up widgets in the main window.""" |
| 43 | self.image_label = QLabel() |
| 44 | self.image_label.setObjectName("ImageLabel") |
| 45 | |
| 46 | # Create various widgets for image processing in the side panel |
| 47 | contrast_label = QLabel("Contrast [Range: 0.0:4.0]") |
| 48 | self.contrast_spinbox = QDoubleSpinBox() |
| 49 | self.contrast_spinbox.setMinimumWidth(100) |
| 50 | self.contrast_spinbox.setRange(0.0, 4.0) |
| 51 | self.contrast_spinbox.setValue(1.0) |
| 52 | self.contrast_spinbox.setSingleStep(.10) |
| 53 | self.contrast_spinbox.valueChanged.connect(self.adjustContrast) |
| 54 | |
| 55 | brightness_label = QLabel("Brightness [Range: -127:127]") |
| 56 | self.brightness_spinbox = QSpinBox() |
| 57 | self.brightness_spinbox.setMinimumWidth(100) |
| 58 | self.brightness_spinbox.setRange(-127, 127) |
| 59 | self.brightness_spinbox.setValue(0) |
| 60 | self.brightness_spinbox.setSingleStep(1) |
| 61 | self.brightness_spinbox.valueChanged.connect(self.adjustBrightness) |
| 62 | |
| 63 | smoothing_label = QLabel("Image Smoothing Filters") |
| 64 | self.filter_2D_cb = QCheckBox("2D Convolution") |
| 65 | self.filter_2D_cb.stateChanged.connect(self.imageSmoothingFilter) |
| 66 | |
| 67 | edges_label = QLabel("Detect Edges") |
| 68 | self.canny_cb = QCheckBox("Canny Edge Detector") |
| 69 | self.canny_cb.stateChanged.connect(self.edgeDetection) |
| 70 | |
| 71 | self.apply_process_button = QPushButton("Apply Processes") |
| 72 | self.apply_process_button.setEnabled(False) |
| 73 | self.apply_process_button.clicked.connect(self.applyImageProcessing) |
| 74 | |
| 75 | reset_button = QPushButton("Reset Image Settings") |
| 76 | reset_button.clicked.connect(self.resetImageAndSettings) |
| 77 | |
| 78 | # Create horizontal and vertical layouts for the side panel and main window |