DWTT自动评定系统算法研究、界面及其逻辑设计

1.程序界面功能效果

2.LoginGui.py登陆界面源码

from PyQt5 import QtCore, QtGui, QtWidgets, Qt
from PyQt5.QtGui import QIcon
from MainFunGui import *
#from hello import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

class Ui_MainWindow(QtWidgets.QMainWindow):

    def __init__(self):
        super(Ui_MainWindow,self).__init__()
        self.setupUi(self)
        self.retranslateUi(self)

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(600, 400)
        MainWindow.setWindowIcon(QIcon('compute.png'))
        MainWindow.setStyleSheet("background-image:url(demo1.jpg)")
        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.centralWidget.setObjectName("centralWidget")
        self.lineEdit = QtWidgets.QLineEdit(self.centralWidget)
        self.lineEdit.setGeometry(QtCore.QRect(250, 70, 100, 20))  #加50
        self.lineEdit.setText("")
        self.lineEdit.setObjectName("lineEdit")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.centralWidget)
        self.lineEdit_2.setGeometry(QtCore.QRect(250, 120, 100, 20))
        self.lineEdit_2.setText("")
        self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.label = QtWidgets.QLabel(self.centralWidget)
        self.label.setGeometry(QtCore.QRect(200, 74, 24, 12))   #加50
        self.label.setTextFormat(QtCore.Qt.AutoText)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralWidget)
        self.label_2.setGeometry(QtCore.QRect(200, 124, 24, 12))
        self.label_2.setObjectName("label_2")
        self.pushButton = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton.setGeometry(QtCore.QRect(190, 180, 75, 23))   #加80
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton_2.setGeometry(QtCore.QRect(350, 180, 75, 23))
        self.pushButton_2.setObjectName("pushButton_2")
        MainWindow.setCentralWidget(self.centralWidget)

        self.pushButton.clicked.connect(self.word_get)
        self.pushButton_2.clicked.connect(MainWindow.close)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "DWTT断口评定系统登录界面"))
        self.lineEdit.setPlaceholderText(_translate("MainWindow", "请输入帐号"))
        self.lineEdit_2.setPlaceholderText(_translate("MainWindow", "请输入密码"))
        self.label.setText(_translate("MainWindow", "帐号"))
        self.label_2.setText(_translate("MainWindow", "密码"))
        self.pushButton.setText(_translate("MainWindow", "确定"))
        self.pushButton_2.setText(_translate("MainWindow", "取消"))

    def word_get(self):
        login_user = self.lineEdit.text()
        login_password = self.lineEdit_2.text()
        if login_user == '周飞达' and login_password == '123456':
            #ui_hello.show()
            #Ui_mainWindow.show()
            ui_MainFunGui.show()
            #mainWindow.show()
            #hello_mainWindow.show()
            MainWindow.close()
        else:
            QMessageBox.warning(self,
                    "警告",
                    "用户名或密码错误!",
                    QMessageBox.Yes)
            self.lineEdit.setFocus()
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui_MainFunGui = MainFunGui_mainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

2.程序的主要逻辑功能模块及其不同模型的预测方法和显示。

#coding:utf-8
import sys
import os
import win32api
from PyQt5 import QtCore, QtGui, QtWidgets
#from PyQt5.QtGui import QIcon
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import QFont
from PyQt5.QAxContainer import QAxWidget
#from pre import *
#import pre
import pandas as pd
import numpy as np
import re

#主界面设计
class MainFunGui_mainWindow(QtWidgets.QMainWindow):
    sig = pyqtSignal()
    def __init__(self):
        super(MainFunGui_mainWindow,self).__init__()
        self.tick_win = None
        self.pushButton1 = QPushButton(self)
        self.setupUi(self)
        self.retranslateUi(self)

    def setupUi(self, mainWindow):
        mainWindow.setObjectName("mainWindow")
        mainWindow.setWindowModality(QtCore.Qt.WindowModal)
        mainWindow.resize(1350, 720)
        self.retranslateUi(mainWindow)
        self.centralWidget = QtWidgets.QWidget(mainWindow)
        self.centralWidget.setObjectName("centralWidget")
        # 字体设计
        font = QtGui.QFont()
        font.setFamily('微软雅黑')
        font.setBold(True)
        font.setPointSize(10)
        font.setWeight(60)
        # 按钮设计
        self.pushButton1 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton1.setGeometry(QtCore.QRect(10, 40, 300, 30))
        self.pushButton1.setStyleSheet("background-color:rgb(164,185,255);")
        self.pushButton1.setText("FCN网络进行DWTT断口图像的语义分割")
        self.pushButton1.setObjectName("pushButton1")
        self.pushButton1.setFont(font)

        self.pushButton2 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton2.setGeometry(QtCore.QRect(10, 80, 300, 30))
        self.pushButton2.setStyleSheet("background-color:rgb(164,185,255);")
        self.pushButton2.setText("DeepLabV3+网络进行DWTT断口图像的语义分割")
        self.pushButton2.setObjectName("pushButton2")
        self.pushButton2.setFont(font)

        self.pushButton3 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton3.setGeometry(QtCore.QRect(10, 120, 300, 30))
        self.pushButton3.setStyleSheet("background-color:rgb(164,185,255);")
        self.pushButton3.setText("Mask R-CNN网络进行DWTT断口图像的实例分割")
        self.pushButton3.setObjectName("pushButton3")
        self.pushButton3.setFont(font)

        self.pushButton4 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton4.setGeometry(QtCore.QRect(1100, 640, 200, 30))
        self.pushButton4.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton4.setText("退出系统")
        self.pushButton4.setObjectName("leave")
        self.pushButton4.setFont(font)
        self.pushButton4.clicked.connect(mainWindow.close)

        self.pushButton5 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton5.setGeometry(QtCore.QRect(750, 60, 200, 30))
        self.pushButton5.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton5.setText("查看fcn评定结果")
        self.pushButton5.setObjectName("calculate")
        self.pushButton5.setFont(font)

        self.pushButton6 = QtWidgets.QPushButton(self.centralWidget)  #打开图像按钮
        self.pushButton6.setGeometry(QtCore.QRect(330, 40, 160, 30))
        #self.pushButton6.setGeometry(QtCore.QRect(890, 60, 200, 30))
        self.pushButton6.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton6.setText("查看FCN分割效果")
        self.pushButton6.setObjectName("OpenfcnPicture")
        self.pushButton6.setFont(font)

        self.pushButton7 = QtWidgets.QPushButton(self.centralWidget)  # 打开图像按钮
        self.pushButton7.setGeometry(QtCore.QRect(330, 80, 160, 30))
        # self.pushButton6.setGeometry(QtCore.QRect(890, 60, 200, 30))
        self.pushButton7.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton7.setText("查看DeepLabv3+分割效果")
        self.pushButton7.setObjectName("Opendeeplabv3+Picture")
        self.pushButton7.setFont(font)

        self.pushButton8 = QtWidgets.QPushButton(self.centralWidget)  # 打开图像按钮
        self.pushButton8.setGeometry(QtCore.QRect(330, 120, 160, 30))
        # self.pushButton6.setGeometry(QtCore.QRect(890, 60, 200, 30))
        self.pushButton8.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton8.setText("查看MaskR-CNN分割效果")
        self.pushButton8.setObjectName("OpenmaskrcnnPicture")
        self.pushButton8.setFont(font)
        #self.pushButton6.clicked.connect(self.openimage)
        self.pushButton9 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton9.setGeometry(QtCore.QRect(1000, 60, 200, 30))
        self.pushButton9.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton9.setText("查看DeepLabv3+评定结果")
        self.pushButton9.setObjectName("calculate")
        self.pushButton9.setFont(font)

        # label设计

        self.label1 = QtWidgets.QLabel(self.centralWidget)
        self.label1.setGeometry(QtCore.QRect(120, 180, 350, 30))
        self.label1.setText("DWTT断口识别结果图像")
        self.label1.setObjectName("label1")
        self.label1.setFont(font)
        self.label1.setStyleSheet("QLabel{background:white;}"
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )

        self.label2 = QtWidgets.QLabel(self.centralWidget)
        self.label2.setGeometry(QtCore.QRect(50, 230, 300, 30))
        self.label2.setText("DWTT断口原始图像")
        self.label2.setObjectName("label2")
        self.label2.setFont(font)
        self.label2.setStyleSheet(
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )

        self.label3 = QtWidgets.QLabel(self.centralWidget)
        self.label3.setGeometry(QtCore.QRect(320, 230, 300, 30))
        self.label3.setText("DWTT断口识别图像")
        self.label3.setObjectName("label3")
        self.label3.setFont(font)
        self.label3.setStyleSheet(
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )

        self.label4 = QtWidgets.QLabel(self.centralWidget)
        self.label4.setGeometry(QtCore.QRect(900, 30, 200, 30))
        self.label4.setText("DWTT断口评定结果(分析)")
        self.label4.setObjectName("label4")
        self.label4.setFont(font)
        self.label4.setStyleSheet(
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )

        self.label5 = QtWidgets.QLabel(self.centralWidget)
        self.label5.setGeometry(QtCore.QRect(600, 120, 200, 30))
        self.label5.setText("DWTT断口评定结果")
        self.label5.setObjectName("label5")
        self.label5.setFont(font)
        self.label5.setStyleSheet(
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )
        self.label6 = QtWidgets.QLabel(self.centralWidget)
        self.label6.setGeometry(QtCore.QRect(600, 400, 200, 30))
        self.label6.setText("DWTT断口评定说明")
        self.label6.setObjectName("label6")
        self.label6.setFont(font)
        self.label6.setStyleSheet(
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )

#打开图像显示区域
        self.label8 = QtWidgets.QLabel(self.centralWidget)
        #self.label8=QLabel(self)
        self.label8.setText("显示原始图像区域")
        self.label8.setGeometry(QtCore.QRect(10, 300, 240, 350))
        self.label8.setStyleSheet("QLabel{background:white;}"
                                 "QLabel{color:rgb(300,300,300,120);font-size:12px;font-family:宋体;}"
                                  )

        self.label9 = QtWidgets.QLabel(self.centralWidget)
        #self.label9 = QLabel(self)
        self.label9.setText("显示预测图像区域")
        # self.label8.setFixedSize(300,200)
        # self.label8.move(160,160)
        self.label9.setGeometry(QtCore.QRect(280, 300, 240, 350))
        self.label9.setStyleSheet("QLabel{background:white;}"
                                  "QLabel{color:rgb(300,300,300,120);font-size:12px;font-family:宋体;}"
                                  )

#打开excel显示区域
        self.tableWidget = QtWidgets.QTableWidget(self.centralWidget)
        self.tableWidget.setGeometry(QtCore.QRect(600, 160, 730, 240))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        self.tableWidget.setStyleSheet("selection-background-color:pink")
        self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableWidget.raise_()

        self.label11 = QtWidgets.QLabel(self.centralWidget)
        #self.label11 = QLabel(self)
        self.label11.setAlignment(Qt.AlignTop)
        self.label11.setText("说明:\n> 表中TS,PTS,GTTS分别表示管材断口原始图像,识别图像和标记图像净截面积的总像素值( 包含背景)\n> FS表示管材断口图像净截面中图像区域的像素值(不含背景),PFS,GTFS分别表示管材断口识别及标记图像脆性区域的像素值\n> FR表示FS和TS之间的比率。PFR表示PFS和PTS之间的比率。GTFR表示GTFS和GTTS之间的比率。\n> APFR,AGFR分别表示管材断口识别图像和标记图像脆性区域所占净截面(不含背景)的比率。\n结果说明:\n>以试样断口规格:305*76*32mm为检测标准,对钢材试样断口剪切面积百分数进行计算(SA)\n> 当SA>=70时,一般评定为安全的断裂行为,当SA<70时,评定为不安全的脆断行为。")
        self.label11.setGeometry(QtCore.QRect(600, 440, 730, 180))
        self.label11.setStyleSheet("QLabel{background:yellow;}"
                                  "QLabel{color:rgb(300,300,300,120);font-size:13px;font-family:宋体;}")


#菜单设计

#信号槽衔接

        mainWindow.setCentralWidget(self.centralWidget)
        QtCore.QMetaObject.connectSlotsByName(mainWindow)

        self.pushButton1.clicked.connect(self.setText_qlabel1)

        self.pushButton2.clicked.connect(self.setText_qlabel2)
        self.pushButton3.clicked.connect(self.setText_qlabel3)
        self.pushButton5.clicked.connect(self.openfile)
        self.pushButton5.clicked.connect(self.creat_table_show)

        self.pushButton6.clicked.connect(self.call_back_btn)
        self.sig.connect(self.call_back_sig)
        self.pushButton7.clicked.connect(self.opendeeplabv3image)
        self.pushButton8.clicked.connect(self.openmaskrcnnimage)
        self.pushButton9.clicked.connect(self.openfile1)
        self.pushButton9.clicked.connect(self.creat_table_show1)
#边框题目定义
    def retranslateUi(self, mainWindow):
        _translate = QtCore.QCoreApplication.translate
        #mainWindow.setWindowTitle(_translate("mainWindow", "hello word"))
        mainWindow.setWindowTitle(_translate("mainWindow",'您好,欢迎来到钢材DWTT断口评定系统(2020)'))
        mainWindow.setWindowIcon(QIcon('compute.png'))
        #菜单设计


#槽函数定义
    def setText_qlabel1(self):
        self.label1.setText('FCN网络进行DWTT断口图像的语义分割')

    def setText_qlabel2(self):
        self.label1.setText('DeepLabV3+网络进行DWTT断口图像的语义分割')
        #win32api.ShellExecute(0, 'open', 'pre.py', '', '', 0)  # 调用预测图像文件执行pre
        #str = ('python pre.py')
        #p = os.system(str)
        #print(p)
        #os.system("python D:/paper/DWTTGUI/pre.py")
        #execfile('pre.py')
        #exec(D:/paper/DWTTGUI/pre.py)
        #execfile('hello.py')
        exec("import deeplabv3pre")
    def setText_qlabel3(self):
        self.label1.setText('Mask R-CNN网络进行DWTT断口图像的实例分割')
        exec("import test_model")


    def opendeeplabv3image(self):               #打开图像槽函数定义
        imgName, imgType = QFileDialog.getOpenFileName(self, "打开图片", "D:\paper\DWTTGUI\deeplabv3+predict_picture", "*.jpg;;*.png;;All Files(*)")
        jpg = QtGui.QPixmap(imgName).scaled(self.label8.width(), self.label8.height())
        self.label8.setPixmap(jpg)
        n=re.findall(r"Example(.+?).jpg",imgName)
        imgName1=''
        imgName1+='D:/paper/DWTTGUI/deeplabv3+predict_result/Example'
        for i in n:
            index=int(i)
        imgName1='D:/paper/DWTTGUI/deeplabv3+predict_result/Example%d'%(index)
        imgName1+='.png'
        jpg1 = QtGui.QPixmap(imgName1).scaled(self.label9.width(), self.label9.height())
        self.label9.setPixmap(jpg1)

    def openmaskrcnnimage(self):               #打开图像槽函数定义
        imgName, imgType = QFileDialog.getOpenFileName(self, "打开图片", "D:\paper\DWTTGUI\maskrcnnimages", "*.jpg;;*.png;;All Files(*)")
        jpg = QtGui.QPixmap(imgName).scaled(self.label8.width(), self.label8.height())
        self.label8.setPixmap(jpg)
        n=re.findall(r"train(.+?).jpg",imgName)
        print(n)
        imgName1=''
        imgName1+='D:/paper/DWTTGUI/test_results(Mresnet101)'
        for i in n:
            index=int(i)
        if(index>=1 and index<=9):
            imgName1 = 'D:/paper/DWTTGUI/test_results(Mresnet101)/0%d' % (index)
        else:
            imgName1='D:/paper/DWTTGUI/test_results(Mresnet101)/%d'%(index)
        imgName1+='.jpg'
        jpg1 = QtGui.QPixmap(imgName1).scaled(self.label9.width(), self.label9.height())
        self.label9.setPixmap(jpg1)

    def openfile(self):     #fcn
        ###获取路径===================================================================
        path= QFileDialog.getOpenFileName(
            self, '打开结果文件', 'E:/letcodepritice/countpix/countpix/FcnStellTestData(name).xls', 'excel(*.xlsx *.xls *.csv)')
        global path_openfile_name
        ###获取路径====================================================================
        path_openfile_name = path[0]

    def creat_table_show(self):    #fcn
        ###===========读取表格,转换表格,===========================================
        if len(path_openfile_name) > 0:
            input_table = pd.read_excel(path_openfile_name)
            input_table_rows = input_table.shape[0]
            input_table_colunms = input_table.shape[1]
            input_table_header = input_table.columns.values.tolist()
        ###===========读取表格,转换表格,============================================
        ###======================给tablewidget设置行列表头============================
            self.tableWidget.setColumnCount(input_table_colunms)
            self.tableWidget.setRowCount(input_table_rows)
            self.tableWidget.setHorizontalHeaderLabels(input_table_header)
        ###======================给tablewidget设置行列表头============================
        ###================遍历表格每个元素,同时添加到tablewidget中========================
            for i in range(input_table_rows):
                input_table_rows_values = input_table.iloc[[i]]
                input_table_rows_values_array = np.array(input_table_rows_values)
                input_table_rows_values_list = input_table_rows_values_array.tolist()[0]
                for j in range(input_table_colunms):
                    input_table_items_list = input_table_rows_values_list[j]
        ###==============将遍历的元素添加到tablewidget中并显示=======================
                    input_table_items = str(input_table_items_list)
                    newItem = QTableWidgetItem(input_table_items)
                    self.tableWidget.setItem(i, j, newItem)
        ###================遍历表格每个元素,同时添加到tablewidget中========================
        else:
            self.centralWidget.show()

    def openfile1(self):     #fcn
        ###获取路径===================================================================
        path= QFileDialog.getOpenFileName(
            self, '打开结果文件', 'E:/letcodepritice/countpix/countpix/deeplabStellTestData.xls', 'excel(*.xlsx *.xls *.csv)')
        global path_openfile_name1
        ###获取路径====================================================================
        path_openfile_name1 = path[0]

    def creat_table_show1(self):    #fcn
        ###===========读取表格,转换表格,===========================================
        if len(path_openfile_name1) > 0:
            input_table = pd.read_excel(path_openfile_name1)
            input_table_rows = input_table.shape[0]
            input_table_colunms = input_table.shape[1]
            input_table_header = input_table.columns.values.tolist()
        ###===========读取表格,转换表格,============================================
        ###======================给tablewidget设置行列表头============================
            self.tableWidget.setColumnCount(input_table_colunms)
            self.tableWidget.setRowCount(input_table_rows)
            self.tableWidget.setHorizontalHeaderLabels(input_table_header)
        ###======================给tablewidget设置行列表头============================
        ###================遍历表格每个元素,同时添加到tablewidget中========================
            for i in range(input_table_rows):
                input_table_rows_values = input_table.iloc[[i]]
                input_table_rows_values_array = np.array(input_table_rows_values)
                input_table_rows_values_list = input_table_rows_values_array.tolist()[0]
                for j in range(input_table_colunms):
                    input_table_items_list = input_table_rows_values_list[j]
        ###==============将遍历的元素添加到tablewidget中并显示=======================
                    input_table_items = str(input_table_items_list)
                    newItem = QTableWidgetItem(input_table_items)
                    self.tableWidget.setItem(i, j, newItem)
        ###================遍历表格每个元素,同时添加到tablewidget中========================
        else:
            self.centralWidget.show()

    def call_back_btn(self):
        self.sig.emit()

    def call_back_sig(self):

        if self.tick_win:
            print("++++++++++++++++++++++ call_back_sig first +++++++++++++++++++++")
            self.tick_win.show()
        else:
            self.tick_win = SecondWindow()
            self.tick_win.show()
            #self.tick_win.move(200, 200)
            print("--------------------- call_back_sig second ----------------")


#导入excel结果文件
#查看fcn网络结果类
class SecondWindow(QMainWindow):

    def __init__(self, parent=None):
        super(SecondWindow, self).__init__(parent)
        self.resize(850, 480)
        self.setWindowTitle('FCN网络评估结果')
        self.pushButton1 = QPushButton(self)
        self.label1 = QtWidgets.QLabel(self)
        self.label2 = QtWidgets.QLabel(self)
        self.label3 = QtWidgets.QLabel(self)
        self.label4 = QtWidgets.QLabel(self)
        self.label5 = QtWidgets.QLabel(self)
        self.label6 = QtWidgets.QLabel(self)
        self.label7 = QtWidgets.QLabel(self)
        # 字体设计
        font = QtGui.QFont()
        font.setFamily('微软雅黑')
        font.setBold(True)
        font.setPointSize(10)
        font.setWeight(60)

        #self.pushButton1 = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton1.setGeometry(QtCore.QRect(0, 0, 200, 30))
        self.pushButton1.setStyleSheet("background-color:rgb(164,255,255);")
        self.pushButton1.setText("查看分割效果")
        self.pushButton1.setObjectName("calculate")
        self.pushButton1.setFont(font)
        self.pushButton1.clicked.connect(self.openimage)
        #self.label1 = QtWidgets.QLabel(self.centralWidget)
        self.label1.setGeometry(QtCore.QRect(250, 30, 350, 30))
        self.label1.setText("FCN网络进行DWTT断口图像的语义分割")
        self.label1.setObjectName("label1")
        self.label1.setFont(font)
        self.label1.setStyleSheet(
                                  "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
                                  )

        #self.label2 = QtWidgets.QLabel(self.centralWidget)
        self.label2.setGeometry(QtCore.QRect(50, 80, 300, 30))
        self.label2.setText("DWTT断口原始图像")
        self.label2.setObjectName("label2")
        self.label2.setFont(font)
        self.label2.setStyleSheet(
            "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
        )

        #self.label3 = QtWidgets.QLabel(self.centralWidget)
        self.label3.setGeometry(QtCore.QRect(320, 80, 300, 30))
        self.label3.setText("DWTT断口识别图像")
        self.label3.setObjectName("label3")
        self.label3.setFont(font)
        self.label3.setStyleSheet(
            "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
        )

        self.label4.setGeometry(QtCore.QRect(590, 80, 300, 30))
        self.label4.setText("DWTT断口标记图像")
        self.label4.setObjectName("label4")
        self.label4.setFont(font)
        self.label4.setStyleSheet(
            "QLabel{color:rgb(300,300,300,120);font-size:14px;font-weight:bold;font-family:宋体;}"
        )

        #self.label8 = QtWidgets.QLabel(self.centralWidget)
        # self.label8=QLabel(self)
        self.label5.setText("显示原始图像区域")
        self.label5.setGeometry(QtCore.QRect(20, 110, 240, 350))
        self.label5.setStyleSheet("QLabel{background:white;}"
                                  "QLabel{color:rgb(300,300,300,120);font-size:12px;font-family:宋体;}"
                                  )

        #self.label9 = QtWidgets.QLabel(self.centralWidget)
        # self.label9 = QLabel(self)
        self.label6.setText("显示预测图像区域")
        # self.label8.setFixedSize(300,200)
        # self.label8.move(160,160)
        self.label6.setGeometry(QtCore.QRect(290, 110, 240, 350))
        self.label6.setStyleSheet("QLabel{background:white;}"
                                  "QLabel{color:rgb(300,300,300,120);font-size:12px;font-family:宋体;}"
                                  )
        #self.label8 = QtWidgets.QLabel(self.centralWidget)
        # self.label8=QLabel(self)
        self.label7.setText("显示标记图像区域")
        self.label7.setGeometry(QtCore.QRect(560, 110, 240, 350))
        self.label7.setStyleSheet("QLabel{background:white;}"
                                  "QLabel{color:rgb(300,300,300,120);font-size:12px;font-family:宋体;}"
                                  )


    #槽函数定义
    def openimage(self):               #打开图像槽函数定义
        imgName, imgType = QFileDialog.getOpenFileName(self, "打开图片", "D:/paper/DWTTGUI/fcnpredict_picture", "*.jpg;;*.png;;All Files(*)")
        jpg = QtGui.QPixmap(imgName).scaled(self.label5.width(), self.label5.height())
        self.label5.setPixmap(jpg)
        n=re.findall(r"train(.+?).jpg",imgName)
        imgName1=''
        imgName1+='D:/paper/DWTTGUI/fcnpredict_gtresult/train0'
        imgName2 = ''
        imgName2 += 'D:/paper/DWTTGUI/fcnpredict_ptresult/pred_train0'
        for i in n:
            i=int(i)
        imgName1='D:/paper/DWTTGUI/fcnpredict_gtresult/train0%d'%(i)
        imgName1+='.png'
        imgName2 = 'D:/paper/DWTTGUI/fcnpredict_ptresult/pred_train0%d' % (i)
        imgName2 += '.png'
        print(imgName1)
        print(imgName2)
        jpg1 = QtGui.QPixmap(imgName2).scaled(self.label6.width(), self.label6.height())
        self.label6.setPixmap(jpg1)
        jpg2 = QtGui.QPixmap(imgName1).scaled(self.label7.width(), self.label7.height())
        self.label7.setPixmap(jpg2)



if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    mainWindow = QtWidgets.QMainWindow()
    ui = MainFunGui_mainWindow()
    ui.setupUi(mainWindow)
    #ui.show()
    mainWindow.show()
    #ui.show()
    sys.exit(app.exec_())

4.钢材DWTT断口面中不同区域(脆性,韧性)的计算和评定

#include "stdafx.h"
#include"stdafx.h"
#include<iostream>
#include <fstream>
#include <string>
#include<iomanip>
#include<math.h>
#include<vector>
#include<highgui.hpp>
#include<cv.hpp>
#include<imgproc.hpp>

using namespace std;
using namespace cv;
/////////////////////全局变量的定义
double TS, FS, PTS, PFS, GTTS, GTFS;
double FR, PFR, GTFR, APFR, AGFR, DER;
////////////////////全局变量的定义
//////////////////////////////////////////////////原始断口数据采集
void outputImageInformation1(const Mat& hi)
{
    ///计算
    int image_count = 1;//要计算直方图的图像的个数
    int channels[1] = { 0 };//图像的通道'

    Mat out;//计算所得直方图
    int dims = 1;//得到直方图的维数
    int histsize[1] = { 256 };//直方图横坐标的子区间数
    float hrange[2] = { 0, 255 };//区间的总范围
    const float *ranges[1] = { hrange };//指针数组

    calcHist(&hi, image_count, channels, Mat(), out, dims, histsize, ranges);

    ///////////////////输出直方图信息
    double maxValue = 0;
    double minValue = 0;
    int a = 0;
    /*
    for (int i = 0; i < out.rows; i++)
    {
    for (int j = 0; j < out.cols; j++)
    {
    float b = out.at<float>(i, j);
    a += 1;
    cout << b << endl;
    }
    }
    */

    int histSize = out.rows;
    //Mat histImage(histSize, histSize, CV_8UC3, Scalar(255, 255, 255));

    //int hpt = static_cast<int>(0.9*histSize);
    int total = 0;

    //Scalar color(255, 0, 0);//BGR
    for (int h = 0; h < histSize; h++)
    {
        float binVal = out.at<float>(h);//读取对应灰度级的像素个数
        if (h % 10 == 0)
        {

            cout << setw(4) << h << ": " << setw(4) << binVal << " ";
            total += binVal;
            cout << endl;
        }
        else
            cout << setw(4) << h << ": " << setw(4) << binVal << " ";
        total += binVal;
    }
    cout << endl;
    minMaxLoc(out, &minValue, &maxValue, 0, 0);//找到全局最小、最大的像素值数目
    cout << "max pix num: " << maxValue << " " << "min pix num: " << minValue << " ";
    cout << "total pix num:" << total << endl;
    TS = total;
    FS = total - maxValue;
    FR = FS / TS;
    cout << "FR=" << FR << endl;
}
////////////////////////////原始断口数据采集

////////////////////////预测断口数据采集
void outputImageInformation2(const Mat& hi)
{
    ///计算
    int image_count = 1;//要计算直方图的图像的个数
    int channels[1] = { 0 };//图像的通道'

    Mat out;//计算所得直方图
    int dims = 1;//得到直方图的维数
    int histsize[1] = { 256 };//直方图横坐标的子区间数
    float hrange[2] = { 0, 255 };//区间的总范围
    const float *ranges[1] = { hrange };//指针数组

    calcHist(&hi, image_count, channels, Mat(), out, dims, histsize, ranges);

    ///////////////////输出直方图信息
    double maxValue = 0;
    double minValue = 0;
    int a = 0;
    /*
    for (int i = 0; i < out.rows; i++)
    {
    for (int j = 0; j < out.cols; j++)
    {
    float b = out.at<float>(i, j);
    a += 1;
    cout << b << endl;
    }
    }
    */

    int histSize = out.rows;
    //Mat histImage(histSize, histSize, CV_8UC3, Scalar(255, 255, 255));

    //int hpt = static_cast<int>(0.9*histSize);
    int total = 0;

    //Scalar color(255, 0, 0);//BGR
    for (int h = 0; h < histSize; h++)
    {
        float binVal = out.at<float>(h);//读取对应灰度级的像素个数
        if (h % 10 == 0)
        {

            cout << setw(4) << h << ": " << setw(4) << binVal << " ";
            total += binVal;
            cout << endl;
        }
        else
            cout << setw(4) << h << ": " << setw(4) << binVal << " ";
        total += binVal;
    }
    cout << endl;
    minMaxLoc(out, &minValue, &maxValue, 0, 0);//找到全局最小、最大的像素值数目
    cout << "max pix num: " << maxValue << " " << "min pix num: " << minValue << " ";
    cout << "total pix num:" << total << endl;
    PTS = total;
    PFS = total - maxValue;
    PFR = PFS / PTS;
}
///////////////////////预测断口数据采集

////////////////////////标记断口数据采集
void outputImageInformation3(const Mat& hi)
{
    ///计算
    int image_count = 1;//要计算直方图的图像的个数
    int channels[1] = { 0 };//图像的通道'

    Mat out;//计算所得直方图
    int dims = 1;//得到直方图的维数
    int histsize[1] = { 256 };//直方图横坐标的子区间数
    float hrange[2] = { 0, 255 };//区间的总范围
    const float *ranges[1] = { hrange };//指针数组

    calcHist(&hi, image_count, channels, Mat(), out, dims, histsize, ranges);

    ///////////////////输出直方图信息
    double maxValue = 0;
    double minValue = 0;
    int a = 0;
    /*
    for (int i = 0; i < out.rows; i++)
    {
    for (int j = 0; j < out.cols; j++)
    {
    float b = out.at<float>(i, j);
    a += 1;
    cout << b << endl;
    }
    }
    */

    int histSize = out.rows;
    //Mat histImage(histSize, histSize, CV_8UC3, Scalar(255, 255, 255));

    //int hpt = static_cast<int>(0.9*histSize);
    int total = 0;

    //Scalar color(255, 0, 0);//BGR
    for (int h = 0; h < histSize; h++)
    {
        float binVal = out.at<float>(h);//读取对应灰度级的像素个数
        if (h % 10 == 0)
        {

            cout << setw(4) << h << ": " << setw(4) << binVal << " ";
            total += binVal;
            cout << endl;
        }
        else
            cout << setw(4) << h << ": " << setw(4) << binVal << " ";
        total += binVal;
    }
    cout << endl;
    minMaxLoc(out, &minValue, &maxValue, 0, 0);//找到全局最小、最大的像素值数目
    cout << "max pix num: " << maxValue << " " << "min pix num: " << minValue << " ";
    cout << "total pix num:" << total << endl;
    GTTS = total;
    GTFS = total - maxValue;
    GTFR = GTFS / GTTS;

    APFR = PFR / FR;
    AGFR = GTFR / FR;
    DER = abs(APFR - AGFR);

}
////////////////////////标记断口数据采集

void getHistImage(const Mat& hist)
{

    ////////////////////绘制直方图
    Mat dstHist;//得到的直方图     
    int dims = 1;//得到的直方图的维数 灰度图的维数为1
    float hranges[2] = { 0, 255 };    //直方图统计的灰度值范围
    const float *ranges[1] = { hranges };   // 这里需要为const类型,二维数组用来指出每个区间的范围  
    int bin = 255;//直方图横坐标的区间数 即横坐标被分成多少份
    int channels = 0;//图像得通道 灰度图的通道数为0
                     /* 计算图像的直方图 */
    calcHist(&hist, 1/*输入图像个数*/, &channels, Mat()/*掩码*/, dstHist, dims, &bin, ranges);
    int height = 150;    //直方图高度
    int scale = 3;    //垂直缩放比
    int horvizon_scale = 3;    //水平缩放比
                            //获取最大值和最小值  
    double minValue = 0;
    double maxValue = 0;
    minMaxLoc(dstHist, &minValue, &maxValue, 0, 0); //找到直方图中的最大值和最小值 

    int shift_vertical = 13;    //直方图偏移值,偏移用于显示水平坐标
    int shift_horvizon = 30;    //直方图偏移值,偏移用于显示垂直坐标
                                //绘制出直方图  
    Mat dstImage(height*scale, bin*horvizon_scale + shift_horvizon, CV_8UC3, Scalar(255, 255, 255)); //图像背景颜色        //创建一个彩色三通道矩阵,大小a*b,填充0
    int hpt = saturate_cast<int>((dstImage.rows - shift_vertical)*0.95); //最大值对应的Y坐标,防止溢出
    for (int i = 0; i < bin; i++)
    {
        float binValue = dstHist.at<float>(i);
        int realValue = saturate_cast<int>(binValue * hpt / maxValue);
        rectangle(dstImage, Point(i*horvizon_scale + shift_horvizon, dstImage.rows - 1 - shift_vertical), Point((i + 1)*horvizon_scale + shift_horvizon - 1, dstImage.rows - realValue - shift_vertical), Scalar(255, 0, 0), 1, 8, 0);
    }
    //绘制垂直刻度
    char string[100];
    CvFont font;
    double font_size = 1;//字体大小
    cvInitFont(&font, CV_FONT_HERSHEY_PLAIN, 1, 1, 0, 1, 8);//字体结构初始化 
    Size text_size;
    for (int i = hpt; i >= 0; )
    {
        _itoa_s(maxValue*i / hpt, string, 10);//把一个整数转换为字符串  
                                              //在图像中显示文本字符串  
        text_size = getTextSize(string, CV_FONT_HERSHEY_PLAIN, font_size, 1, NULL);    //获得字体大小
        putText(dstImage, string, cvPoint(0, dstImage.rows - i - shift_vertical + text_size.height / 2), cv::FONT_HERSHEY_PLAIN, font_size, Scalar(0, 0, 0), 1, 8, 0);
        i -= hpt / 10;    //只显示10个刻度
    }
    //刻画水平刻度
    for (int i = bin; i >= 0;)
    {
        _itoa_s(i, string, 10);//把一个整数转换为字符串  
                               //在图像中显示文本字符串  
        text_size = getTextSize(string, CV_FONT_HERSHEY_PLAIN, font_size, 1, NULL);    //获得字体大小
        putText(dstImage, string, cvPoint(i*horvizon_scale + shift_horvizon - text_size.width / 2, dstImage.rows), cv::FONT_HERSHEY_PLAIN, font_size, Scalar(0, 0, 0), 1, 8, 0);
        i -= bin / 10;    //只显示20个刻度
    }
    //显示统计信息
    sprintf_s(string, " Range from 0 to %d", (int)hranges[1]);
    putText(dstImage, string, cvPoint(dstImage.cols / 5, 30), cv::FONT_HERSHEY_PLAIN, (double)1.3, Scalar(0, 0, 0), 1, 8, 0);
    imshow("灰度直方图", dstImage);


}

int main(int argc, _TCHAR* argv[])
{


    //Mat src = imread("E:\\letcodepritice\\countpix\\picset\\prediction6.png",-1);

    //IplImage* image = cvLoadImage("D:/timg.jpg");
    //Mat src = imread("E://graduation//traditionMethods//Kmeans2forImage//Kmeans2forImage//Debug//testset//scissor1+.jpg", -1);
    ///////////////////图像的原图和灰度图显示
    /*
    int a = src.channels();//a = 3通道
    imshow("原图", src);
    if (!src.data)
    {
    cout << "no picture!\n";
    exit(1);
    }
    cvtColor(src, src, CV_BGR2GRAY, 0);
    a = src.channels();//a = 1通道
    imshow("灰度图", src);
    */
    //////////////////////////////////

    //////////////////////////将生成的数据保存到excel文件当中,第一次使用
    ofstream oFile;
    oFile.open("FCNStellTestData.csv", ios::out | ios::trunc);
    oFile << "图像" << "," << "TS" << "," << "FS" << "," << "FR" << "," << "PTS" << "," << "PFS" << "," << "PFR(%)" << "," << "GTTS" << "," << "GTFS" << "," << "GTFR(%)" << "," << "APFR(%)" << "," << "AGFR(%)" << "," << "APSA(%)" << "," << "AGSA(%)" << "," << "DER(%)" << endl;


    //oFile << "010101" << "," << "1 2 3" << "," << "32.2 112.3;23.12 23.22;23.14 23.45" << "," << "1" << endl;
    //oFile.close();
    ////////////////////////////////

    /*
    int image_count = 1;//要计算直方图的图像的个数
    int channels[1] = { 0 };//图像的通道'

    Mat out;//计算所得直方图
    int dims = 1;//得到直方图的维数
    int histsize[1] = { 256 };//直方图横坐标的子区间数
    float hrange[2] = { 0, 255 };//区间的总范围
    const float *ranges[1] = { hrange };//指针数组

    calcHist(&src, image_count, channels, Mat(), out, dims, histsize, ranges);
    */
    for (int i = 0; i < 40; i++)
        //for (int i = 0; i < 16; i++)
    {
        ////////////////1.保存原始试样断口图像信息
        //vector<string> name1 = {"qj1.jpg","qj2.jpg","qj3.jpg","qj4.jpg","qj5.jpg","qj6.jpg"};
        //vector<string> name1 = {"qj1.jpg","qj2.jpg","qj3.jpg","qj4.jpg","qj5.jpg","qj6.jpg","qj7.jpg","qj8.jpg","qj9.jpg","qj10.jpg","qj11.jpg","qj12.jpg","qj13.jpg","qj14.jpg","qj15.jpg","qj16.jpg"};
        //vector<string> name1 = { "qjExample1.jpg","qjExample2.jpg", "qjExample3.jpg", "qjExample4.jpg", "qjExample5.jpg", "qjExample6.jpg", "qjExample7.jpg", "qjExample8.jpg", "qjExample9.jpg", "qjExample10.jpg", "qjExample11.jpg", "qjExample12.jpg", "qjExample13.jpg", "qjExample14.jpg", "qjExample15.jpg", "qjExample16.jpg" };
        vector<string> name = { "train01002","train01010", "train01013", "train01015", "train01016", "train01017", "train01018", "train01019", "train01020", "train01023", "train01027", "train01032", "train01033", "train01034", "train01036", "train01038", "train01043", "train01053", "train01060", "train01061", "train01062", "train01070", "train01071", "train01074", "train01083", "train01084", "train01097", "train01099", "train01101", "train01102", "train01103", "train01104", "train01106", "train01108", "train01109", "train01115", "train01121", "train01124", "train01129", "train01134" };
        vector<string> name1 = {"qjtrain01002.jpg","qjtrain01010.jpg", "qjtrain01013.jpg", "qjtrain01015.jpg", "qjtrain01016.jpg", "qjtrain01017.jpg", "qjtrain01018.jpg", "qjtrain01019.jpg", "qjtrain01020.jpg", "qjtrain01023.jpg", "qjtrain01027.jpg", "qjtrain01032.jpg", "qjtrain01033.jpg", "qjtrain01034.jpg", "qjtrain01036.jpg", "qjtrain01038.jpg", "qjtrain01043.jpg", "qjtrain01053.jpg", "qjtrain01060.jpg", "qjtrain01061.jpg", "qjtrain01062.jpg", "qjtrain01070.jpg", "qjtrain01071.jpg", "qjtrain01074.jpg", "qjtrain01083.jpg", "qjtrain01084.jpg", "qjtrain01097.jpg", "qjtrain01099.jpg", "qjtrain01101.jpg", "qjtrain01102.jpg", "qjtrain01103.jpg", "qjtrain01104.jpg", "qjtrain01106.jpg", "qjtrain01108.jpg", "qjtrain01109.jpg", "qjtrain01115.jpg", "qjtrain01121.jpg", "qjtrain01124.jpg", "qjtrain01129.jpg", "qjtrain01134.jpg"};
        //Mat src = imread("C:\\Users\\thinkpad\\Desktop\\石油管材与仪器投稿\\第二次实验\\picture\\qj16.jpg", -1);
        //Mat src = imread("E:\\FCN\\FCN.tensorflow-master\\FCN.tensorflow-master\\logs\\imageoutput\\fcn实验计算\\"+name1[i], -1);
        //Mat src = imread("D:\\paper\\DWTTGUI\\deeplabv3+predict_picture\\" + name1[i], -1);
        Mat src = imread("D:\\paper\\DWTTGUI\\fcnpredict_picture\\" + name1[i], -1);
        //Mat src = imread("C:\\Users\\thinkpad\\Desktop\\石油管材与仪器投稿\\第二次实验\\picture\\" + name1[i], -1);
        ///////////////////图像的原图和灰度图显示

        int a = src.channels();//a = 3通道
        imshow("原图", src);
        if (!src.data)
        {
            cout << "no picture!\n";
            exit(1);
        }
        cvtColor(src, src, CV_BGR2GRAY, 0);
        a = src.channels();//a = 1通道
        imshow("灰度图", src);
        //////////////////////////////////
        outputImageInformation1(src); //输出原始图像信息
                                      //ofstream oFile;
                                      //oFile.open("StellTestData.csv", ios::out | ios::trunc);
        //oFile << "Group" << i + 1 << "," << TS << "," << FS << "," << FR * 100;
        oFile << name[i] << "," << TS << "," << FS << "," << FR * 100;
        //oFile << "010101" << "," << "1 2 3" << "," << "32.2 112.3;23.12 23.22;23.14 23.45" << "," << "1" << endl;
        //oFile.close();

        ////////////////////////////////////////////////////////

        ////////////////2.保存预测试样断口图像信息
        //vector<string> name2 = { "p1.png","p2.png","p3.png","p4.png","p5.png","p6.png" };
        //vector<string> name2 = { "Example1.png","Example2.png", "Example3.png", "Example4.png", "Example5.png", "Example6.png", "Example7.png", "Example8.png", "Example9.png", "Example10.png", "Example11.png", "Example12.png", "Example13.png", "Example14.png", "Example15.png", "Example16.png" };
        vector<string> name2 = { "pred_train01002.png","pred_train01010.png", "pred_train01013.png", "pred_train01015.png", "pred_train01016.png", "pred_train01017.png", "pred_train01018.png", "pred_train01019.png", "pred_train01020.png", "pred_train01023.png", "pred_train01027.png", "pred_train01032.png", "pred_train01033.png", "pred_train01034.png", "pred_train01036.png", "pred_train01038.png", "pred_train01043.png", "pred_train01053.png", "pred_train01060.png", "pred_train01061.png", "pred_train01062.png", "pred_train01070.png", "pred_train01071.png", "pred_train01074.png", "pred_train01083.png", "pred_train01084.png", "pred_train01097.png", "pred_train01099.png", "pred_train01101.png", "pred_train01102.png", "pred_train01103.png", "pred_train01104.png", "pred_train01106.png", "pred_train01108.png", "pred_train01109.png", "pred_train01115.png", "pred_train01121.png", "pred_train01124.png", "pred_train01129.png", "pred_train01134.png" };
        //vector<string> name2 = {"prediction1.png","prediction2.png","prediction3.png","prediction4.png","prediction5.png","prediction6.png","prediction7.png","prediction8.png","prediction9.png","prediction10.png","prediction11.png","prediction12.png","prediction13.png","prediction14.png","prediction15.png","prediction16.png"};
        //Mat psrc = imread("C:\\Users\\thinkpad\\Desktop\\石油管材与仪器投稿\\第二次实验\\prediction\\prediction16.png", -1);
        //Mat psrc = imread("D:\\paper\\DWTTGUI\\deeplabv3+predict_result\\" + name2[i], -1);
        Mat psrc = imread("D:\\paper\\DWTTGUI\\fcnpredict_ptresult\\" + name2[i], -1);
        //Mat psrc = imread("C:\\Users\\thinkpad\\Desktop\\石油管材与仪器投稿\\第二次实验\\prediction\\" + name2[i], -1);
        ///////////////////图像的原图和灰度图显示
        int p = psrc.channels();//a = 3通道
        imshow("原图", psrc);
        if (!psrc.data)
        {
            cout << "no picture!\n";
            exit(1);
        }
        cvtColor(psrc, psrc, CV_BGR2GRAY, 0);
        p = psrc.channels();//a = 1通道
        imshow("灰度图", psrc);
        //////////////////////////////////
        outputImageInformation2(psrc); //输出原始图像信息
                                       //ofstream oFile;
                                       //oFile.open("StellTestData.csv", ios::out | ios::trunc);
        oFile << "," << PTS << "," << PFS << "," << PFR * 100;
        //oFile << "010101" << "," << "1 2 3" << "," << "32.2 112.3;23.12 23.22;23.14 23.45" << "," << "1" << endl;
        //oFile.close();

        ////////////////////////////////////////////////////////

        ////////////////3.保存标记试样断口图像信息
        //vector<string> name3 = { "g1.png","g2.png","g3.png","g4.png","g5.png","g6.png" };
        vector<string> name3 = { "train01002.png","train01010.png", "train01013.png", "train01015.png", "train01016.png", "train01017.png", "train01018.png", "train01019.png", "train01020.png", "train01023.png", "train01027.png", "train01032.png", "train01033.png", "train01034.png", "train01036.png", "train01038.png", "train01043.png", "train01053.png", "train01060.png", "train01061.png", "train01062.png", "train01070.png", "train01071.png", "train01074.png", "train01083.png", "train01084.png", "train01097.png", "train01099.png", "train01101.png", "train01102.png", "train01103.png", "train01104.png", "train01106.png", "train01108.png", "train01109.png", "train01115.png", "train01121.png", "train01124.png", "train01129.png", "train01134.png" };
        //vector<string> name3 = {"gt1.png","gt2.png","gt3.png","gt4.png","gt5.png","gt6.png","gt7.png","gt8.png","gt9.png","gt10.png","gt11.png","gt12.png","gt13.png","gt14.png","gt15.png","gt16.png"};
        //Mat gsrc = imread("C:\\Users\\thinkpad\\Desktop\\石油管材与仪器投稿\\第二次实验\\labels\\gt16.png", -1);
        //Mat gsrc = imread("E:\\FCN\\FCN.tensorflow-master\\FCN.tensorflow-master\\logs\\imageoutput\\fcn实验计算\\" + name3[i], -1);
        Mat gsrc = imread("D:\\paper\\DWTTGUI\\fcnpredict_gtresult\\" + name3[i], -1);
        //Mat gsrc = imread("C:\\Users\\thinkpad\\Desktop\\石油管材与仪器投稿\\第二次实验\\labels\\" + name3[i], -1);
        ///////////////////图像的原图和灰度图显示
        int g = gsrc.channels();//a = 3通道
        imshow("原图", gsrc);
        if (!gsrc.data)
        {
            cout << "no picture!\n";
            exit(1);
        }
        cvtColor(gsrc, gsrc, CV_BGR2GRAY, 0);
        g = gsrc.channels();//a = 1通道
        imshow("灰度图", gsrc);
        //////////////////////////////////
        outputImageInformation3(gsrc); //输出原始图像信息
                                       //ofstream oFile;
                                       //oFile.open("StellTestData.csv", ios::out | ios::trunc);
        oFile << "," << GTTS << "," << GTFS << "," << GTFR * 100 << "," << APFR * 100 << "," << AGFR * 100 << "," << 100 - APFR * 100 << "," << 100 - AGFR * 100 << "," << DER * 100 << endl;
        //oFile << "010101" << "," << "1 2 3" << "," << "32.2 112.3;23.12 23.22;23.14 23.45" << "," << "1" << endl;
        //oFile.close();

        ////////////////////////////////////////////////////////

    }
    //getHistImage(src);        //绘制直方图

    waitKey();
    return 0;
}

5.评定结果图像及其数据文件

(1)FCN网络预测
钢材DWTT原始图像

FCN网络识别图像

(2)DeepLab网络预测结果图

 

(3)Mask-Rcnn网络预测结果图像

预测的结果数据

图像	TS	FS	FR	PTS	PFS	PFR(%)	GTTS	GTFS	GTFR(%)	APFR(%)	AGFR(%)	APSA(%)	AGSA(%)	DER(%)
train01002	140264	104819	74.7298	132647	17784	13.407	131072	14746	11.2503	17.9407	15.0546	82.0593	84.9454	2.88601
train01010	138792	89173	64.2494	132238	22493	17.0095	131072	17742	13.5361	26.4742	21.068	73.5258	78.932	5.40614
train01013	139338	93449	67.0664	132148	11949	9.04213	131072	14434	11.0123	13.4824	16.4199	86.5176	83.5801	2.93759
train01015	138248	83447	60.3604	132062	8850	6.7014	131072	10050	7.66754	11.1023	12.7029	88.8977	87.2971	1.60063
train01016	139086	90965	65.402	132916	21026	15.819	131072	6214	4.74091	24.1874	7.24887	75.8126	92.7511	16.9385
train01017	139374	95156	68.2739	132168	11696	8.84934	131072	4534	3.45917	12.9615	5.06661	87.0385	94.9334	7.89493
train01018	138454	83351	60.2012	132224	19382	14.6585	131072	21470	16.3803	24.3491	27.2093	75.6509	72.7907	2.86016
train01019	138083	81276	58.8603	132319	17545	13.2596	131072	19715	15.0414	22.5273	25.5543	77.4727	74.4457	3.02705
train01020	138891	89939	64.7551	131965	11089	8.40299	131072	12313	9.39407	12.9766	14.5071	87.0234	85.4929	1.53052
train01023	138709	86324	62.2339	132528	18415	13.8952	131072	4794	3.65753	22.3273	5.87707	77.6727	94.1229	16.4503
train01027	139330	96573	69.3124	132794	45755	34.4556	131072	54491	41.5733	49.7106	59.9796	50.2894	40.0204	10.269
train01032	139877	100207	71.6394	132283	18197	13.7561	131072	17577	13.4102	19.2019	18.719	80.7981	81.281	0.482873
train01033	139737	97185	69.5485	132677	57977	43.6979	131072	56889	43.4029	62.8308	62.4066	37.1692	37.5934	0.42415
train01034	138242	83666	60.5214	132197	15239	11.5275	131072	5519	4.21066	19.047	6.95731	80.953	93.0427	12.0897
train01036	139770	98485	70.4622	132289	16714	12.6345	131072	14930	11.3907	17.9308	16.1657	82.0692	83.8343	1.76516
train01038	139247	94923	68.1688	132239	14291	10.8069	131072	12222	9.32465	15.8532	13.6788	84.1468	86.3212	2.17446
train01043	139728	99218	71.008	132420	17933	13.5425	131072	14172	10.8124	19.0718	15.227	80.9282	84.773	3.84483
train01053	140013	103332	73.8017	133004	34621	26.03	131072	41541	31.6933	35.2702	42.9438	64.7298	57.0562	7.67357
train01060	138772	88659	63.8882	132014	12098	9.16418	131072	9435	7.19833	14.3441	11.2671	85.6559	88.7329	3.07701
train01061	139106	92083	66.1963	132272	19203	14.5178	131072	13105	9.99832	21.9315	15.1041	78.0685	84.8959	6.82741
train01062	140099	101325	72.3239	132232	22618	17.1048	131072	20092	15.329	23.6503	21.1949	76.3497	78.8051	2.45535
train01070	139587	97138	69.5896	132789	18627	14.0275	131072	10261	7.82852	20.1575	11.2496	79.8425	88.7504	8.90794
train01071	141359	116925	82.7149	132495	22984	17.3471	131072	15183	11.5837	20.9721	14.0044	79.0279	85.9956	6.96774
train01074	141054	116466	82.5684	132341	19044	14.3901	131072	13817	10.5415	17.4281	12.767	82.5719	87.233	4.66106
train01083	139867	99642	71.2405	132459	33035	24.9398	131072	32380	24.704	35.0079	34.6769	64.9921	65.3231	0.33101
train01084	139521	95661	68.5639	132729	50525	38.0663	131072	34272	26.1475	55.5195	38.1359	44.4805	61.8641	17.3835
train01097	140291	103871	74.0397	132481	27721	20.9245	131072	24427	18.6363	28.2612	25.1707	71.7388	74.8293	3.09049
train01099	139687	97989	70.149	132208	19133	14.4719	131072	31722	24.202	20.6302	34.5008	79.3698	65.4992	13.8706
train01101	139522	96445	69.1253	132149	10803	8.17486	131072	12774	9.74579	11.8262	14.0987	88.1738	85.9013	2.27258
train01102	140267	105154	74.967	132106	14520	10.9912	131072	9754	7.44171	14.6613	9.92665	85.3387	90.0734	4.7347
train01103	139938	99737	71.2723	132173	13802	10.4424	131072	9866	7.52716	14.6514	10.5611	85.3486	89.4389	4.09025
train01104	140148	104206	74.3543	132225	14898	11.2672	131072	12851	9.80453	15.1533	13.1862	84.8467	86.8138	1.9671
train01106	140883	109740	77.8944	132749	56460	42.5314	131072	54984	41.9495	54.6013	53.8543	45.3987	46.1457	0.747077
train01108	140972	110981	78.7256	132416	23250	17.5583	131072	21944	16.7419	22.3032	21.2662	77.6968	78.7338	1.03697
train01109	140150	101764	72.6108	132285	25082	18.9606	131072	26813	20.4567	26.1126	28.1731	73.8874	71.8269	2.06046
train01115	139572	96532	69.1629	132437	22056	16.654	131072	25288	19.2932	24.0793	27.8953	75.9207	72.1047	3.816
train01121	139260	93454	67.1076	132594	19656	14.8242	131072	14880	11.3525	22.0902	16.9169	77.9098	83.0831	5.17328
train01124	140160	102341	73.0173	132381	18920	14.2921	131072	14724	11.2335	19.5736	15.3847	80.4264	84.6153	4.18882
train01129	141571	120141	84.8627	132392	22470	16.9723	131072	14094	10.7529	19.9997	12.6709	80.0003	87.3291	7.32884
train01134	139162	93734	67.356	132013	15225	11.533	131072	12480	9.52148	17.1224	14.1361	82.8776	85.8639	2.98633

 

  

源代码及其模型下载:

【1】https://download.csdn.net/download/hopegrace/12500343

【2】https://download.csdn.net/download/hopegrace/12500292

 

posted @ 2020-06-05 11:28  浪里飞  阅读(1127)  评论(0编辑  收藏  举报