主頁 > 後端開發 > DWTT自動評定系統演算法研究、界面及其邏輯設計

DWTT自動評定系統演算法研究、界面及其邏輯設計

2020-09-29 21:41:54 後端開發

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 = https://www.cnblogs.com/mydomain/p/0;
    double minValue = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/0;
    double minValue = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/0;
    double minValue = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/0;
    double maxValue = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/dstHist.at<float>(i);
        int realValue = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/imread("E:\\letcodepritice\\countpix\\picset\\prediction6.png",-1);

    //IplImage* image = cvLoadImage("D:/timg.jpg");
    //Mat src = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/imread("C:\\Users\\thinkpad\\Desktop\\石油管材與儀器投稿\\第二次實驗\\picture\\qj16.jpg", -1);
        //Mat src = https://www.cnblogs.com/mydomain/p/imread("E:\\FCN\\FCN.tensorflow-master\\FCN.tensorflow-master\\logs\\imageoutput\\fcn實驗計算\\"+name1[i], -1);
        //Mat src = https://www.cnblogs.com/mydomain/p/imread("D:\\paper\\DWTTGUI\\deeplabv3+predict_picture\\" + name1[i], -1);
        Mat src = https://www.cnblogs.com/mydomain/p/imread("D:\\paper\\DWTTGUI\\fcnpredict_picture\\" + name1[i], -1);
        //Mat src = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/imread("C:\\Users\\thinkpad\\Desktop\\石油管材與儀器投稿\\第二次實驗\\prediction\\prediction16.png", -1);
        //Mat psrc = https://www.cnblogs.com/mydomain/p/imread("D:\\paper\\DWTTGUI\\deeplabv3+predict_result\\" + name2[i], -1);
        Mat psrc = https://www.cnblogs.com/mydomain/p/imread("D:\\paper\\DWTTGUI\\fcnpredict_ptresult\\" + name2[i], -1);
        //Mat psrc = https://www.cnblogs.com/mydomain/p/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 = https://www.cnblogs.com/mydomain/p/imread("C:\\Users\\thinkpad\\Desktop\\石油管材與儀器投稿\\第二次實驗\\labels\\gt16.png", -1);
        //Mat gsrc = https://www.cnblogs.com/mydomain/p/imread("E:\\FCN\\FCN.tensorflow-master\\FCN.tensorflow-master\\logs\\imageoutput\\fcn實驗計算\\" + name3[i], -1);
        Mat gsrc = https://www.cnblogs.com/mydomain/p/imread("D:\\paper\\DWTTGUI\\fcnpredict_gtresult\\" + name3[i], -1);
        //Mat gsrc = https://www.cnblogs.com/mydomain/p/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

 

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/139937.html

標籤:Python

上一篇:【Python原始碼剖析】物件模型概述

下一篇:SyntaxError: Missing parentheses in call to 'print'. Did you mean print

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more