# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import numpy as np
from PyQt5.QtWidgets import QFileDialog,QFrame
from PIL import ImageEnhance
from PIL import Image, ImageFilter
from PIL import ImageQt
from medpy.metric.binary import dc
from medpy.metric.binary import hd,hd95
from random import random
import cv2
from main import generate_image,graphbased_segmentation,threshold_func,diff
from graph import build_graph, segment_graph
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(Ui_MainWindow,self).__init__()
self.setupUi(self)
self.retranslateUi(self)
self.pp = None # 当前处理结果
def setupUi(self, MainWindow):
MainWindow.setObjectName("图像处理工具")
MainWindow.resize(982, 613)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(450, 30, 481, 531))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.label_2 = QtWidgets.QLabel(self.verticalLayoutWidget)
self.label_2.setScaledContents(True)
self.label_2.setObjectName("label_2")
self.label_2.setStyleSheet(
'border-width: 1px;border-style: solid;border-color: rgb(190, 190, 190);background-color: rgb(226, 233, 236);')
self.verticalLayout.addWidget(self.label_2)
self.label = QtWidgets.QLabel(self.verticalLayoutWidget)
self.label.setScaledContents(True)
self.label.setObjectName("label")
self.label.setStyleSheet(
'border-width: 1px;border-style: solid;border-color: rgb(190, 190, 190);background-color: rgb(226, 233, 236);')
self.verticalLayout.addWidget(self.label)
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(60, 90, 321, 281))
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.pushButton_2 = QtWidgets.QPushButton(self.tab)
self.pushButton_2.setGeometry(QtCore.QRect(100, 50, 121, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.tab)
self.pushButton_3.setGeometry(QtCore.QRect(100, 110, 121, 31))
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalSlider = QtWidgets.QSlider(self.tab)
self.horizontalSlider.setGeometry(QtCore.QRect(120, 170, 160, 22))
self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider.setObjectName("horizontalSlider")
self.horizontalSlider.setMinimum(0)
# 设置最大值
self.horizontalSlider.setMaximum(10)
# 设置步长
self.horizontalSlider.setSingleStep(1)
self.label_11 = QtWidgets.QLabel(self.tab)
self.label_11.setGeometry(QtCore.QRect(30, 173, 90, 15))
self.label_11.setObjectName("label_11")
self.label_12 = QtWidgets.QLabel(self.tab)
self.label_12.setGeometry(QtCore.QRect(120, 200, 90, 15))
self.label_12.setObjectName("label_12")
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.pushButton_4 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_4.setGeometry(QtCore.QRect(92, 40, 121, 31))
self.pushButton_4.setObjectName("pushButton_4")
self.pushButton_5 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_5.setGeometry(QtCore.QRect(90, 140, 121, 31))
self.pushButton_5.setObjectName("pushButton_5")
self.label_3 = QtWidgets.QLabel(self.tab_2)
self.label_3.setGeometry(QtCore.QRect(80, 100, 72, 15))
self.label_3.setObjectName("label_3")
self.doubleSpinBox = QtWidgets.QDoubleSpinBox(self.tab_2)
self.doubleSpinBox.setGeometry(QtCore.QRect(150, 90, 81, 31))
self.doubleSpinBox.setProperty("value", 3.0)
self.doubleSpinBox.setObjectName("doubleSpinBox")
self.doubleSpinBox.setMaximum(100)
self.doubleSpinBox.setMinimum(1)
self.doubleSpinBox.setSingleStep(1)
self.doubleSpinBox_2 = QtWidgets.QDoubleSpinBox(self.tab_2)
self.doubleSpinBox_2.setGeometry(QtCore.QRect(150, 190, 81, 31))
self.doubleSpinBox_2.setProperty("value", 3.0)
self.doubleSpinBox_2.setObjectName("doubleSpinBox_2")
self.doubleSpinBox_2.setMaximum(99)
self.doubleSpinBox_2.setMinimum(1)
self.doubleSpinBox_2.setSingleStep(2)
self.label_13 = QtWidgets.QLabel(self.tab_2)
self.label_13.setGeometry(QtCore.QRect(80, 200, 72, 15))
self.label_13.setObjectName("label_5")
self.tabWidget.addTab(self.tab_2, "")
self.tab_3 = QtWidgets.QWidget()
self.tab_3.setObjectName("tab_3")
self.pushButton = QtWidgets.QPushButton(self.tab_3)
self.pushButton.setGeometry(QtCore.QRect(170, 100, 93, 28))
self.pushButton.setObjectName("pushButton")
self.label_6 = QtWidgets.QLabel(self.tab_3)
self.label_6.setGeometry(QtCore.QRect(60, 20, 201, 31))
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.tab_3)
self.label_7.setGeometry(QtCore.QRect(20, 50, 72, 15))
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(self.tab_3)
self.label_8.setGeometry(QtCore.QRect(120, 140, 181, 91))
self.label_8.setObjectName("label_8")
self.label_8.setStyleSheet(
'border-width: 1px;border-style: solid;border-color: rgb(190, 190, 190);background-color: rgb(243, 249, 250);')
self.label_9 = QtWidgets.QLabel(self.tab_3)
self.label_9.setGeometry(QtCore.QRect(35, 150, 81, 16))
self.label_9.setObjectName("label_9")
self.pushButton_7 = QtWidgets.QPushButton(self.tab_3)
self.pushButton_7.setGeometry(QtCore.QRect(170, 60, 93, 28))
self.pushButton_7.setObjectName("pushButton_7")
self.tabWidget.addTab(self.tab_3, "")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(80, 390, 190, 15))
self.label_4.setObjectName("label_4")
self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_6.setGeometry(QtCore.QRect(290, 500, 93, 28))
self.pushButton_6.setObjectName("pushButton_6")
self.label_10 = QtWidgets.QLabel(self.centralwidget)
self.label_10.setGeometry(QtCore.QRect(80, 460, 72, 15))
self.label_10.setObjectName("label_10")
self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_3.setGeometry(QtCore.QRect(150, 450, 231, 31))
self.lineEdit_3.setObjectName("lineEdit_3")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menuBar = QtWidgets.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 982, 26))
self.menuBar.setObjectName("menuBar")
self.menu = QtWidgets.QMenu(self