diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..105fcab
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1659212497308
+
+
+ 1659212497308
+
+
+ 1659212660585
+
+
+
+ 1659212660585
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/.idea/.gitignore b/DILCode/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/DILCode/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/DILCode/.idea/DILProject2.iml b/DILCode/.idea/DILProject2.iml
new file mode 100644
index 0000000..d0876a7
--- /dev/null
+++ b/DILCode/.idea/DILProject2.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/.idea/inspectionProfiles/Project_Default.xml b/DILCode/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1102411
--- /dev/null
+++ b/DILCode/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/.idea/inspectionProfiles/profiles_settings.xml b/DILCode/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/DILCode/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/.idea/misc.xml b/DILCode/.idea/misc.xml
new file mode 100644
index 0000000..a2e120d
--- /dev/null
+++ b/DILCode/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/.idea/modules.xml b/DILCode/.idea/modules.xml
new file mode 100644
index 0000000..703bd11
--- /dev/null
+++ b/DILCode/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/.idea/vcs.xml b/DILCode/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/DILCode/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DILCode/ColorMenu.py b/DILCode/ColorMenu.py
new file mode 100644
index 0000000..637d6ed
--- /dev/null
+++ b/DILCode/ColorMenu.py
@@ -0,0 +1,52 @@
+import math
+import cv2
+import numpy as np
+import struct
+import matplotlib.pyplot as plt
+
+class ColorMenu:
+ #读取彩色图片
+ def __init__(self, pic_path):
+ self.pic_path = pic_path
+ self.pic = cv2.imread(self.pic_path, 1).astype(np.uint8)
+ self.b = self.pic[:, :, 0]
+ self.g = self.pic[:, :, 1]
+ self.r = self.pic[:, :, 2]
+
+ hsv = cv2.cvtColor(self.pic, cv2.COLOR_BGR2HSV)
+ self.h = hsv[:, :, 0]
+ self.s = hsv[:, :, 1]
+ self.v = hsv[:, :, 2]
+
+ def ShowPic(self):
+ cv2.imshow('当前图片', self.pic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+
+ #RGB
+ def Bchannel(self):
+ cv2.imwrite('img/colorImgs/Cchannel.jpg', self.b)
+ # cv2.imshow('Bchannel', self.b)
+ cv2.waitKey(0)
+ def Gchannel(self):
+ cv2.imwrite('img/colorImgs/Cchannel.jpg', self.g)
+ #cv2.imshow('Gchannel', self.g)
+ cv2.waitKey(0)
+ def Rchannel(self):
+ cv2.imwrite('img/colorImgs/Cchannel.jpg', self.r)
+ #cv2.imshow('Gchannel', self.r)
+ cv2.waitKey(0)
+
+ #HSV
+ def Hchannel(self):
+ cv2.imwrite('img/colorImgs/Cchannel.jpg', self.h)
+ #cv2.imshow('Hchannel', self.h)
+ cv2.waitKey(0)
+ def Schannel(self):
+ cv2.imwrite('img/colorImgs/Cchannel.jpg', self.s)
+ #cv2.imshow('Schannel', self.s)
+ cv2.waitKey(0)
+ def Vchannel(self):
+ cv2.imwrite('img/colorImgs/Cchannel.jpg', self.v)
+ #cv2.imshow('Vchannel', self.v)
+ cv2.waitKey(0)
\ No newline at end of file
diff --git a/DILCode/Main_UI.py b/DILCode/Main_UI.py
new file mode 100644
index 0000000..0d14215
--- /dev/null
+++ b/DILCode/Main_UI.py
@@ -0,0 +1,402 @@
+import sys
+import warnings
+import cv2
+import numpy as np
+import struct
+import matplotlib.pyplot as plt
+
+from PyQt5 import QtWidgets, QtGui
+
+from ColorMenu import ColorMenu
+from geometryMenu import geometryMenu
+from mophologyMenu import mophologyMenu
+from edgeMenu import EdgeMenu
+from filterMenu import FilterMenu
+from faceDetect import FaceDetect
+from ui_file_1 import Ui_mainWindow
+from PyQt5.QtWidgets import QMessageBox, QFileDialog, QInputDialog, QLineEdit
+from qt_material import apply_stylesheet
+
+
+class WXTWindow(QtWidgets.QMainWindow, Ui_mainWindow):
+ def __init__(self):
+ self.default_save_path = 'img'
+ super(WXTWindow, self).__init__()
+ self.setupUi(self)
+ #QMessageBox.about(self.window(), "使用提示", "欢迎使用~ 在对图像进行操作前,请先选择要处理的图片~")
+ self.pic_path = "" # 初始化空值
+ self.menubar.setEnabled(True)
+ self.color_menu.setEnabled(False)
+ self.geo_menu.setEnabled(False)
+ self.histogram_menu.setEnabled(False)
+ self.mophology_menu.setEnabled(False)
+ self.advancecd_menu.setEnabled(False)
+ self.denoising_menu.setEnabled(False)
+ self.faceMenu.setEnabled(False)
+ self.Save_btn.setEnabled(False)
+
+ # 打开图片
+ def OpenImg(self):
+ imgName, imgType = QFileDialog.getOpenFileName(self, "打开图片", "OriginPictures", "*.jpg;;*.bmp;;*.png")
+ jpg = QtGui.QPixmap(imgName).scaled(self.ori_pic.width(), self.ori_pic.height(), 1 ,1)
+ self.ori_pic.setPixmap(jpg)
+
+ self.origin_pic_path.setText(imgName)
+ self.pic_path = imgName
+ self.fixed_pic.setText("")
+ self.fixed_pic.clear()
+
+ if self.pic_path == "":
+ self.color_menu.setEnabled(False)
+ self.geo_menu.setEnabled(False)
+ self.histogram_menu.setEnabled(False)
+ self.mophology_menu.setEnabled(False)
+ self.advancecd_menu.setEnabled(False)
+ self.denoising_menu.setEnabled(False)
+ self.faceMenu.setEnabled(False)
+ self.Save_btn.setEnabled(False)
+ return
+
+ #各部分初始化
+ self.Initialize_color()
+ self.Initialize_geo()
+ self.InitializeMopho()
+ self.InitializeEdge()
+ self.InitializeFilter()
+
+ self.color_menu.setEnabled(True)
+ self.geo_menu.setEnabled(True)
+ self.histogram_menu.setEnabled(True)
+ self.mophology_menu.setEnabled(True)
+ self.advancecd_menu.setEnabled(True)
+ self.denoising_menu.setEnabled(True)
+ self.faceMenu.setEnabled(True)
+ self.Save_btn.setEnabled(True)
+
+ def SaveImg(self):
+ if self.save_pic_path.text() == "默认保存在img文件夹":
+ QMessageBox.information(self, "提示", "尚未进行图片操作,不能保存")
+ return
+
+ if self.pic_path != "" :
+ imgURL = QFileDialog.getExistingDirectory(self, "保存图片", "SavedPictures")
+ savepic = cv2.imread(self.save_pic_path.text(), 1)
+ cv2.imwrite(imgURL + '/SavedPic.jpg', savepic)
+
+
+ # 显示保存的图片
+ def Show_Fixed_Pic(self, path):
+ jpg = QtGui.QPixmap(path).scaled(self.fixed_pic.width(), self.fixed_pic.height(), 1, 1)
+ self.fixed_pic.setPixmap(jpg)
+ self.save_pic_path.setText(path)
+
+ # 显示位图信息头
+ def Show_Pic_Info(self):
+ pass
+
+
+
+ #以下为色彩菜单函数
+ def Initialize_color(self):
+ self.color = ColorMenu(self.pic_path)
+
+ def GreyPic(self):
+ greypic = cv2.imread(self.pic_path, 0)
+ cv2.imwrite('img/greyimg.jpg', greypic)
+ self.Show_Fixed_Pic('img/greyimg.jpg')
+
+ def ExtractBchannel(self):
+ self.color.Bchannel()
+ self.Show_Fixed_Pic('img/colorImgs/Cchannel.jpg')
+
+ def ExtractGchannel(self):
+ self.color.Gchannel()
+ self.Show_Fixed_Pic('img/colorImgs/Cchannel.jpg')
+
+ def ExtractRchannel(self):
+ self.color.Rchannel()
+ self.Show_Fixed_Pic('img/colorImgs/Cchannel.jpg')
+
+ def ExtractHchannel(self):
+ self.color.Hchannel()
+ self.Show_Fixed_Pic('img/colorImgs/Cchannel.jpg')
+
+ def ExtractSchannel(self):
+ self.color.Schannel()
+ self.Show_Fixed_Pic('img/colorImgs/Cchannel.jpg')
+
+ def ExtractVchannel(self):
+ self.color.Vchannel()
+ self.Show_Fixed_Pic('img/colorImgs/Cchannel.jpg')
+
+
+
+ #以下为移动菜单函数
+
+ def Initialize_geo(self):
+ self.geoOperation = geometryMenu(self.pic_path)
+
+ def MovePic(self):
+ numx, ok1 = QInputDialog.getInt(self, 'X轴移动值', '请输入向右移动的值', 0, -10000, 10000, 10)
+ numy, ok2 = QInputDialog.getInt(self, 'Y轴移动值', '请输入向下移动的值', 0, -10000, 10000, 10)
+
+ if ok1 and ok2:
+ #if numx != 0 or numy != 0:
+ self.geoOperation.ImageMove(numx, numy)
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def ImageResizeTimes(self):
+ numx, ok1 = QInputDialog.getDouble(self, '横向放缩值', '请输入横向放缩值', 1, 0.01, 5, 1)
+ numy, ok2 = QInputDialog.getDouble(self, '纵向放缩值', '请输入纵向放缩值', 1, 0.01, 5, 1)
+
+ if ok1 and ok2:
+ if numx != 1 or numy != 1:
+ self.geoOperation.ImageResizeTimes(numx, numy)
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def ImageResizePixel(self):
+ numx, ok1 = QInputDialog.getInt(self, '横向像素值', '请输入横向像素值', 8, 8, 20000, 1)
+ numy, ok2 = QInputDialog.getInt(self, '纵向像素值', '请输入纵向像素值', 8, 8, 20000, 1)
+
+ if ok1 and ok2:
+ self.geoOperation.ImageResizePixel(numx, numy)
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def HorizontalFlip(self):
+ self.geoOperation.HorizentalFlip()
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def VerticalFlip(self):
+ self.geoOperation.VerticalFlip()
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def CrossFlip(self):
+ self.geoOperation.CrossFlip()
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def FreeRotate(self):
+ angle, ok1 = QInputDialog.getInt(self, '角度', '请输入顺时针旋转角度', 0, -360, 360, 1)
+ size, ok2 = QInputDialog.getDouble(self, '放缩值', '请输入放缩值,默认为1无需更改', 1, 0.01, 5, 1)
+
+ if ok1 and ok2:
+ self.geoOperation.FreeRotate(angle, size)
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+ def FixedRotate(self):
+ items = ('90', '180', '270')
+ angle, ok = QInputDialog.getItem(self, '角度', '请输入顺时针旋转角度', items, 0, False)
+
+ if ok:
+ self.geoOperation.FixedRotate(angle)
+ self.Show_Fixed_Pic('img/geometryImgs/moved_pic.jpg')
+
+
+
+ #以下为直方图函数
+ def DrawGreyHistogram(self):
+ greypic = cv2.imread(self.pic_path, 0)
+ hist = cv2.calcHist([greypic], [0], None, [256], [0, 256])
+ plt.plot(hist)
+ plt.xlim([0, 255])
+ plt.savefig('img/histogram/histogram.jpg')
+ plt.close()
+ self.Show_Fixed_Pic('img/histogram/histogram.jpg')
+
+ def DrawRGBHistogram(self):
+ pic = cv2.imread(self.pic_path, 1)
+ color = ('r', 'g', 'b')
+ for i, col in enumerate(color):
+ hist = cv2.calcHist([pic], [i], None, [256], [0, 256])
+ plt.plot(hist)
+ plt.xlim([0, 256])
+
+ plt.savefig('img/histogram/histogram.jpg')
+ plt.close()
+ self.Show_Fixed_Pic('img/histogram/histogram.jpg')
+
+
+
+ #以下为形态学运算函数
+ def InitializeMopho(self):
+ self.mophology = mophologyMenu(self.pic_path)
+
+ def Erode(self):
+ size, ok = QInputDialog.getInt(self, '腐蚀结构元大小', '请输入,默认为5', 5, 1, 1000, 1)
+
+ if ok:
+ self.mophology.Erode(size)
+ self.Show_Fixed_Pic('img/mophologyImgs/mophoPic.jpg')
+
+ def Dilate(self):
+ size, ok = QInputDialog.getInt(self, '膨胀结构元大小', '请输入,默认为5', 5, 1, 1000, 1)
+
+ if ok:
+ self.mophology.Dilate(size)
+ self.Show_Fixed_Pic('img/mophologyImgs/mophoPic.jpg')
+
+ def OpenOperate(self):
+ size, ok = QInputDialog.getInt(self, '开运算结构元大小', '请输入,默认为5', 5, 1, 1000, 1)
+
+ if ok:
+ self.mophology.Open(size)
+ self.Show_Fixed_Pic('img/mophologyImgs/mophoPic.jpg')
+ def CloseOperate(self):
+ size, ok = QInputDialog.getInt(self, '闭运算结构元大小', '请输入,默认为5', 5, 1, 1000, 1)
+
+ if ok:
+ self.mophology.Close(size)
+ self.Show_Fixed_Pic('img/mophologyImgs/mophoPic.jpg')
+
+
+
+ #以下为图像增强以及边缘检测、锐化函数
+ def InitializeEdge(self):
+ self.edgeOpe = EdgeMenu(self.pic_path)
+
+ def PicStrength(self):
+ self.edgeOpe.PicStrength()
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def RobertsOperation(self):
+ self.edgeOpe.EdgeRoberts()
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def SobelOperation(self):
+ self.edgeOpe.EdgeSobel()
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def LaplacianOperation(self):
+ items = ('1', '3', '5', '7')
+ size, ok = QInputDialog.getItem(self, 'Laplacian算子大小', '请输入,默认为1', items, 0, False)
+
+ if ok:
+ self.edgeOpe.EdgeLaplacian(size)
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def LoGOperation(self):
+ QMessageBox.information(self, "提示", "LoG算子运算较慢请耐心等待")
+
+ self.edgeOpe.EdgeLoG()
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def CannyOperation(self):
+ self.edgeOpe.EdgeCanny()
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def HoughStraight(self):
+ colors = ['red', 'green', 'blue', 'black', 'white']
+ color, ok1 = QInputDialog.getItem(self, '线条颜色', '请输入,默认为红', colors, 0, False)
+ thres, ok2 = QInputDialog.getInt(self, '阈值', '请输入阈值,阈值越大检测出的线段越长越少,默认为100', 100, 1, 1000, 1)
+
+ if ok1 and ok2:
+ self.edgeOpe.HoughDetect(thres, color)
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+ def HoughCurve(self):
+ colors = ['red', 'green', 'blue', 'black', 'white']
+ color, ok1 = QInputDialog.getItem(self, '线条颜色', '请输入,默认为红', colors, 0, False)
+ thres, ok2 = QInputDialog.getInt(self, '阈值', '请输入阈值,阈值越大检测出的线段越长越少,默认为100', 100, 1, 1000, 1)
+ minline, ok3 = QInputDialog.getInt(self, '线段最小长度', '请输入线段最小长度,默认为0', 0, 0, 1000, 1)
+ maxgap, ok4 = QInputDialog.getInt(self, '线段间最大允许间隔', '请输入间隔默认为0', 0, 0, 1000, 1)
+
+ if ok1 and ok2 and ok3 and ok4:
+ self.edgeOpe.HoughDetectP(thres, minline, maxgap, color)
+ self.Show_Fixed_Pic('img/EdgeImgs/EdgePic.jpg')
+
+
+
+
+
+
+ #以下为去噪相关部分槽函数
+ def InitializeFilter(self):
+ self.filterOpe = FilterMenu(self.pic_path)
+
+ def GaussNoise(self):
+ avg, ok1 = QInputDialog.getDouble(self, '均值', '请输入均值', 0, 0, 100)
+ var, ok2 = QInputDialog.getDouble(self, '方差', '请输入方差', 0.5, 0, 100)
+
+ if ok1 and ok2:
+ self.filterOpe.GaussNoise(avg,var)
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def PepperSaltyNoise(self):
+ thres, ok1 = QInputDialog.getDouble(self, '噪声阈值', '请输入阈值', 0.2, 0.01, 0.99)
+
+ if ok1:
+ self.filterOpe.PepperSaltyNoise(thres)
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def GaussFilter(self):
+ sizes, ok = QInputDialog.getInt(self, '高斯核大小', '请输入,必须为奇数,默认为1', 1, 1, 15)
+
+ if ok:
+ if sizes % 2 == 1:
+ self.filterOpe.gaussFilter(sizes)
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+ else:
+ QMessageBox.information(self, "提示", "输入的核大小必须为奇数")
+
+ def AvgFilter(self):
+ self.filterOpe.AverageFilter()
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def MidFilter(self):
+ self.filterOpe.middleFilter()
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def minFilter(self):
+ self.filterOpe.LeastFilter()
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def maxFilter(self):
+ self.filterOpe.LargestFilter()
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def PassFilter(self):
+ items = ('0', '255')
+
+ min, ok1 = QInputDialog.getInt(self, '带通范围', '请输入最低范围,至少0', 20, 0, 255)
+ max, ok2 = QInputDialog.getInt(self, '带通范围', '请输入最高范围,至多255', 220, 0, 255)
+ num, ok3 = QInputDialog.getItem(self, '非滤指定值', '请选择', items, 0, False)
+
+ if ok1 and ok2 and ok3:
+ self.filterOpe.PassFilter(min, max, num)
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ def BlockFilter(self):
+ items = ('0', '255')
+
+ min, ok1 = QInputDialog.getInt(self, '带阻范围', '请输入最低范围,至少0', 20, 0, 255)
+ max, ok2 = QInputDialog.getInt(self, '带阻范围', '请输入最高范围,至多255', 220, 0, 255)
+ num, ok3 = QInputDialog.getItem(self, '非滤指定值', '请选择', items, 0, False)
+
+ if ok1 and ok2 and ok3:
+ self.filterOpe.BlockFilter(min, max, num)
+ self.Show_Fixed_Pic('img/filterImgs/FilterPic.jpg')
+
+ #以下是人脸识别
+ def faceDetect(self):
+ self.facedtct = FaceDetect(self.pic_path)
+ self.facedtct.detectFace()
+ self.Show_Fixed_Pic('img/faceImg/facePic.jpg')
+
+ def videoDetect(self):
+ self.facedtct = FaceDetect(self.pic_path)
+ try:
+ self.facedtct.videoDetect()
+ except Exception as e:
+ QMessageBox.information(self, "提示", "退出了人脸识别")
+
+
+
+
+
+
+if __name__ == '__main__':
+ warnings.filterwarnings('ignore')
+ app = QtWidgets.QApplication(sys.argv)
+ myWin = WXTWindow()
+ apply_stylesheet(app, theme='light_cyan.xml')
+ myWin.show()
+ sys.exit(app.exec_())
\ No newline at end of file
diff --git a/DILCode/OriginPictures/1.jpg b/DILCode/OriginPictures/1.jpg
new file mode 100644
index 0000000..8b30f74
Binary files /dev/null and b/DILCode/OriginPictures/1.jpg differ
diff --git a/DILCode/edgeMenu.py b/DILCode/edgeMenu.py
new file mode 100644
index 0000000..3189fbc
--- /dev/null
+++ b/DILCode/edgeMenu.py
@@ -0,0 +1,186 @@
+import math
+import cv2
+import numpy as np
+import struct
+import matplotlib.pyplot as plt
+from PyQt5.QtWidgets import QMessageBox
+
+class EdgeMenu:
+ def __init__(self, pic_path):
+ self.pic_path = pic_path
+ self.pic = cv2.imread(self.pic_path, 0).astype(np.uint8) #灰度模式读取
+ self.cpic = cv2.imread(self.pic_path, 1).astype(np.uint8)
+
+ def ShowPic(self):
+ cv2.imshow('当前图片', self.pic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+ def PicStrength(self):
+ self.pic = self.pic.astype('float')
+ row, column = self.pic.shape
+ gradient = np.zeros((row, column))
+
+ for x in range(row - 1):
+ for y in range(column - 1):
+ gx = abs(self.pic[x + 1, y] - self.pic[x, y])
+ gy = abs(self.pic[x, y + 1] - self.pic[x, y])
+ gradient[x, y] = gx + gy
+
+ # 3. 对图像进行增强,增强后的图像变量名为sharp
+ sharp = self.pic + gradient
+ sharp = np.where(sharp > 255, 255, sharp)
+ sharp = np.where(sharp < 0, 0, sharp)
+ gradient = gradient.astype('uint8')
+ sharp = sharp.astype('uint8')
+
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', sharp)
+ cv2.waitKey(0)
+
+ def EdgeRoberts(self):
+ kernelx = np.array([[-1, 0], [0, 1]], dtype=int)
+ kernely = np.array([[0, -1], [1, 0]], dtype=int)
+ x = cv2.filter2D(self.pic, cv2.CV_16S, kernelx)
+ y = cv2.filter2D(self.pic, cv2.CV_16S, kernely)
+ absX = cv2.convertScaleAbs(x)
+ absY = cv2.convertScaleAbs(y)
+ Roberts = cv2.addWeighted(absX, 0.5, absY, 0.5, 0)
+
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', Roberts)
+ cv2.waitKey(0)
+
+ def EdgeSobel(self):
+ x = cv2.Sobel(self.pic, cv2.CV_16S, 1, 0)
+ y = cv2.Sobel(self.pic, cv2.CV_16S, 0, 1)
+ absX = cv2.convertScaleAbs(x)
+ absY = cv2.convertScaleAbs(y)
+ Sobel = cv2.addWeighted(absX, 0.5, absY, 0.5, 0)
+
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', Sobel)
+ cv2.waitKey(0)
+
+ def EdgeLaplacian(self, k_size):
+ grayImage = cv2.GaussianBlur(self.pic, (5, 5), 0, 0)
+ # 3. 拉普拉斯算法
+ if k_size == '1':
+ dst = cv2.Laplacian(grayImage, cv2.CV_16S, ksize=1)
+ elif k_size == '3':
+ dst = cv2.Laplacian(grayImage, cv2.CV_16S, ksize=3)
+ elif k_size == '5':
+ dst = cv2.Laplacian(grayImage, cv2.CV_16S, ksize=5)
+ elif k_size == '7':
+ dst = cv2.Laplacian(grayImage, cv2.CV_16S, ksize=7)
+ else:
+ return
+ # 4. 数据格式转换
+ Laplacian = cv2.convertScaleAbs(dst)
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', Laplacian)
+ cv2.waitKey(0)
+
+ def EdgeLoG(self):
+ img = cv2.imread(self.pic_path)
+ grayImage = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
+ # 2. 边缘扩充处理图像
+ image = cv2.copyMakeBorder(grayImage, 2, 2, 2, 2, borderType=cv2.BORDER_REPLICATE)
+ image = cv2.GaussianBlur(image, (3, 3), 0, 0)
+ # 3. 使用Numpy定义LoG算子
+ m1 = np.array(
+ [[0, 0, -1, 0, 0], [0, -1, -2, -1, 0], [-1, -2, 16, -2, -1], [0, -1, -2, -1, 0], [0, 0, -1, 0, 0]])
+
+ rows = image.shape[0]
+ cols = image.shape[1]
+ image1 = np.zeros(image.shape)
+
+ # 4. 卷积运算
+ for k in range(0, 2):
+ for i in range(2, rows - 2):
+ for j in range(2, cols - 2):
+ image1[i, j] = np.sum((m1 * image[i - 2:i + 3, j - 2:j + 3, k]))
+
+ image1 = cv2.convertScaleAbs(image1)
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', image1)
+ cv2.waitKey(0)
+
+ def EdgeCanny(self):
+ self.picColor = cv2.imread(self.pic_path, 1).astype(np.uint8) #彩色模式读取
+ # 2. 灰度转换
+ blur = cv2.cvtColor(self.picColor, cv2.COLOR_BGR2GRAY)
+ # 3. 求x,y方向的Sobel算子
+ gradx = cv2.Sobel(blur, cv2.CV_16SC1, 1, 0)
+ grady = cv2.Sobel(blur, cv2.CV_16SC1, 0, 1)
+ # 4. 使用Canny函数处理图像,x,y分别是3求出来的梯度,低阈值50,高阈值150
+ edge_output = cv2.Canny(gradx, grady, 50, 150)
+
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', edge_output)
+ cv2.waitKey(0)
+
+ def HoughDetect(self, threshold, color):
+ img = cv2.GaussianBlur(self.cpic, (3, 3), 0)
+ edges = cv2.Canny(img, 50, 150, apertureSize=3)
+
+ lines = cv2.HoughLines(edges, 1, np.pi / 2, threshold)
+ result = img.copy()
+
+ if lines is None:
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', result)
+ return
+
+ for i_line in lines:
+ for line in i_line:
+ rho = line[0]
+ theta = line[1]
+ if (theta < (np.pi / 4.)) or (theta > (3. * np.pi / 4.0)): # 垂直直线
+ pt1 = (int(rho / np.cos(theta)), 0)
+ pt2 = (int((rho - result.shape[0] * np.sin(theta)) / np.cos(theta)), result.shape[0])
+ if color == 'red':
+ cv2.line(result, pt1, pt2, (0, 0, 255))
+ if color == 'white':
+ cv2.line(result, pt1, pt2, (255, 255, 255))
+ if color == 'black':
+ cv2.line(result, pt1, pt2, (0, 0, 0))
+ if color == 'green':
+ cv2.line(result, pt1, pt2, (0, 255, 0))
+ if color == 'blue':
+ cv2.line(result, pt1, pt2, (0, 255, 0))
+ else:
+ pt1 = (0, int(rho / np.sin(theta)))
+ pt2 = (result.shape[1], int((rho - result.shape[1] * np.cos(theta)) / np.sin(theta)))
+ if color == 'red':
+ cv2.line(result, pt1, pt2, (0, 0, 255), 1)
+ if color == 'white':
+ cv2.line(result, pt1, pt2, (255, 255, 255), 1)
+ if color == 'black':
+ cv2.line(result, pt1, pt2, (0, 0, 0), 1)
+ if color == 'green':
+ cv2.line(result, pt1, pt2, (0, 255, 0), 1)
+ if color == 'blue':
+ cv2.line(result, pt1, pt2, (0, 255, 0), 1)
+
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', result)
+ cv2.waitKey(0)
+
+ def HoughDetectP(self, threshold, MinLineLength, MaxLineGap, color):
+ img = cv2.GaussianBlur(self.cpic, (3, 3), 0)
+ edges = cv2.Canny(img, 50, 150, apertureSize=3)
+ linesP = cv2.HoughLinesP(edges, 1, np.pi / 180, threshold, minLineLength = MinLineLength,maxLineGap = MaxLineGap)
+
+ result_P = img.copy()
+
+ if linesP is None:
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', result_P)
+ return
+
+ for i_P in linesP:
+ for x1, y1, x2, y2 in i_P:
+ if color == 'red':
+ cv2.line(result_P, (x1, y1), (x2, y2), (0, 0, 255), 3)
+ if color == 'white':
+ cv2.line(result_P, (x1, y1), (x2, y2), (255, 255, 255), 3)
+ if color == 'black':
+ cv2.line(result_P, (x1, y1), (x2, y2), (0, 0, 0), 3)
+ if color == 'green':
+ cv2.line(result_P, (x1, y1), (x2, y2), (0, 255, 0), 3)
+ if color == 'blue':
+ cv2.line(result_P, (x1, y1), (x2, y2), (255, 0, 0), 3)
+
+ cv2.imwrite('img/EdgeImgs/EdgePic.jpg', result_P)
+ cv2.waitKey(0)
\ No newline at end of file
diff --git a/DILCode/faceDetect.py b/DILCode/faceDetect.py
new file mode 100644
index 0000000..5c48cb6
--- /dev/null
+++ b/DILCode/faceDetect.py
@@ -0,0 +1,61 @@
+import cv2
+import dlib
+import numpy as np
+import matplotlib.pyplot as plt
+from imutils import face_utils
+
+class FaceDetect:
+ def __init__(self, pic_path):
+ self.pic_path = pic_path
+
+ if pic_path != "":
+ self.pic = cv2.imread(self.pic_path, 1).astype(np.uint8)
+
+
+ def ShowPic(self):
+ cv2.imshow('当前图片', self.pic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+ def detectFace(self):
+ im = np.float32(self.pic) / 255.0
+ # Calculate gradient
+ gx = cv2.Sobel(im, cv2.CV_32F, 1, 0, ksize=1)
+ gy = cv2.Sobel(im, cv2.CV_32F, 0, 1, ksize=1)
+ mag, angle = cv2.cartToPolar(gx, gy, angleInDegrees=True)
+ self.facePic = self.pic
+
+ face_detect = dlib.get_frontal_face_detector()
+ rects = face_detect(self.pic, 1)
+ for (i, rect) in enumerate(rects):
+ (x, y, w, h) = face_utils.rect_to_bb(rect)
+ self.facePic = cv2.rectangle(self.pic, (x, y), (x + w, y + h), (255, 255, 255), 3)
+
+ cv2.imwrite("img/faceImg/facePic.jpg", self.facePic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+ def videoDetect(self):
+ video_capture = cv2.VideoCapture(0)
+ face_detect = dlib.get_frontal_face_detector()
+ flag = 0
+
+ while True:
+
+ ret, frame = video_capture.read()
+
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+ rects = face_detect(gray, 1)
+
+ for (i, rect) in enumerate(rects):
+ (x, y, w, h) = face_utils.rect_to_bb(rect)
+
+ cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
+
+ cv2.imshow('Face detect, Press ESC Quit', frame)
+
+ if cv2.waitKey(3) is 27:
+ break
+ if cv2.getWindowProperty('Face detect, Press ESC Quit', cv2.WND_PROP_AUTOSIZE) < 1:
+ break
+
+ video_capture.release()
+ cv2.destroyWindow(self)
diff --git a/DILCode/filterMenu.py b/DILCode/filterMenu.py
new file mode 100644
index 0000000..5fbc2a3
--- /dev/null
+++ b/DILCode/filterMenu.py
@@ -0,0 +1,206 @@
+import math
+import cv2
+import numpy as np
+import struct
+import matplotlib.pyplot as plt
+import random
+
+class FilterMenu:
+ def __init__(self, pic_path):
+ self.pic_path = pic_path
+ self.pic = cv2.imread(self.pic_path, 1).astype(np.uint8)
+ self.greypic = cv2.imread(self.pic_path, cv2.IMREAD_GRAYSCALE).astype(np.uint8)
+
+ def ShowPic(self):
+ cv2.imshow('当前图片', self.pic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+ def GaussNoise(self, average, variance):
+ # 将图片的像素值归一化,存入矩阵中
+ image = np.array(self.pic / 255, dtype=float)
+ # 生成正态分布的噪声,其中0表示均值,0.1表示方差
+ noise = np.random.normal(average, variance, image.shape)
+ # 将噪声叠加到图片上
+ out = image + noise
+ # 将图像的归一化像素值控制在0和1之间,防止噪声越界
+ out = np.clip(out, 0.0, 1.0)
+ # 将图像的像素值恢复到0到255之间
+ out = np.uint8(out * 255)
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', out)
+ cv2.waitKey(0)
+
+ def PepperSaltyNoise(self, threshold):
+
+ # 待输出的图片
+ output = np.zeros(self.pic.shape, np.uint8)
+ # 椒盐噪声的阈值
+ prob = threshold
+ thres = 1 - prob
+ # 遍历图像,获取叠加噪声后的图像
+ for i in range(self.pic.shape[0]):
+ for j in range(self.pic.shape[1]):
+ rdn = random.random()
+ if rdn < prob:
+ # 添加胡椒噪声
+ output[i][j] = 0
+ elif rdn > thres:
+ # 添加食盐噪声
+ output[i][j] = 255
+ else:
+ # 不添加噪声
+ output[i][j] = self.pic[i][j]
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
+
+ def gaussFilter(self, core):
+ num = core
+
+ grayImage = cv2.GaussianBlur(self.pic, (num, num), 0)
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', grayImage)
+ cv2.waitKey(0)
+
+ def AverageFilter(self):
+ output = np.zeros(self.greypic.shape, np.uint8)
+ # 遍历图像,进行均值滤波
+ for i in range(self.greypic.shape[0]):
+ for j in range(self.greypic.shape[1]):
+ # 滤波器内像素值的和
+ sum = 0
+ # 遍历滤波器内的像素值
+ for m in range(-1, 2):
+ for n in range(-1, 2):
+ # 防止越界
+ if 0 <= i + m < self.greypic.shape[0] and 0 <= j + n < self.greypic.shape[1]:
+ # 像素值求和
+ sum += self.greypic[i + m][j + n]
+ # 求均值,作为最终的像素值
+ output[i][j] = int(sum / 9)
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
+
+ # 获取列表的中间值的函数
+ def get_middle(self, array):
+ # 列表的长度
+ length = len(array)
+ # 对列表进行选择排序,获得有序的列表
+ for i in range(length):
+ for j in range(i + 1, length):
+ # 选择最大的值
+ if array[j] > array[i]:
+ # 交换位置
+ temp = array[j]
+ array[j] = array[i]
+ array[i] = temp
+ return array[int(length / 2)]
+
+ def middleFilter(self):
+ output = np.zeros(self.greypic.shape, np.uint8)
+ # 存储滤波器范围内的像素值
+ self.array = []
+ # 遍历图像,进行中值滤波
+ for i in range(self.greypic.shape[0]):
+ for j in range(self.greypic.shape[1]):
+ # 清空滤波器内的像素值
+ self.array.clear()
+ # 遍历滤波器内的像素
+ for m in range(-1, 2):
+ for n in range(-1, 2):
+ # 防止越界
+ if 0 <= i + m < self.greypic.shape[0] and 0 <= j + n < self.greypic.shape[1]:
+ # 像素值加到列表中
+ self.array.append(self.greypic[i + m][j + n])
+ # 求中值,作为最终的像素值
+ output[i][j] = self.get_middle(self.array)
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
+
+ def LeastFilter(self):
+ output = np.zeros(self.greypic.shape, np.uint8)
+ ######### Begin #########
+ for i in range(self.greypic.shape[0]):
+ for j in range(self.greypic.shape[1]):
+ # 最小值滤波器
+ minone = 0
+ for m in range(-1, 2):
+ for n in range(-1, 2):
+ if 0 <= i + m < self.greypic.shape[0] and 0 <= j + n < self.greypic.shape[1]:
+ # 通过比较判断是否需要更新最小值
+ if self.greypic[i + m][j + n] < minone:
+ minone = self.greypic[i + m][j + n]
+
+ # 更新最小值
+ output[i][j] = minone
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
+
+ def LargestFilter(self):
+ output = np.zeros(self.greypic.shape, np.uint8)
+ ######### Begin #########
+ for i in range(self.greypic.shape[0]):
+ for j in range(self.greypic.shape[1]):
+ # 最大值滤波器
+ maxone = 0
+ for m in range(-1, 2):
+ for n in range(-1, 2):
+ if 0 <= i + m < self.greypic.shape[0] and 0 <= j + n < self.greypic.shape[1]:
+ # 通过比较判断是否需要更新最大值
+ if self.greypic[i + m][j + n] > maxone:
+ maxone = self.greypic[i + m][j + n]
+
+ # 更新最小值
+ output[i][j] = maxone
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
+
+ def PassFilter(self, rangemin, rangemax, filt_num):
+ # 待输出的图片
+ output = np.zeros(self.greypic.shape, np.uint8)
+ # 遍历图像,进行均值滤波
+ array = []
+ # 带通的范围
+ min = rangemin
+ max = rangemax
+ for i in range(self.greypic.shape[0]):
+ for j in range(self.greypic.shape[1]):
+ # 滤波器内像素值的和
+ array.clear()
+ if min < self.greypic[i][j] < max:
+ output[i][j] = self.greypic[i][j]
+ else:
+ if filt_num == '0':
+ output[i][j] = 0
+ elif filt_num == '255':
+ output[i][j] = 255
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
+
+ def BlockFilter(self, rangemin, rangemax, filt_num):
+ # 待输出的图片
+ output = np.zeros(self.greypic.shape, np.uint8)
+ # 遍历图像,进行均值滤波
+ array = []
+ # 带阻的范围
+ min = rangemin
+ max = rangemax
+ for i in range(self.greypic.shape[0]):
+ for j in range(self.greypic.shape[1]):
+ # 滤波器内像素值的和
+ array.clear()
+ if min < self.greypic[i][j] < max:
+ if filt_num == '0':
+ output[i][j] = 0
+ elif filt_num == '255':
+ output[i][j] = 255
+ else:
+ output[i][j] = self.greypic[i][j]
+
+ cv2.imwrite('img/filterImgs/FilterPic.jpg', output)
+ cv2.waitKey(0)
\ No newline at end of file
diff --git a/DILCode/geometryMenu.py b/DILCode/geometryMenu.py
new file mode 100644
index 0000000..e8a562a
--- /dev/null
+++ b/DILCode/geometryMenu.py
@@ -0,0 +1,76 @@
+import math
+import cv2
+import numpy as np
+import struct
+import matplotlib.pyplot as plt
+
+class geometryMenu:
+ # 读取彩色图片
+ def __init__(self, pic_path):
+ self.pic_path = pic_path
+ self.pic = cv2.imread(self.pic_path, 1).astype(np.uint8)
+
+ def ShowPic(self):
+ cv2.imshow('当前图片', self.pic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+ #二维移动,向右x,向下y
+ def ImageMove(self, x, y):
+ height, width, channel = self.pic.shape
+ M = np.float32([[1, 0, x], [0, 1, y]])
+ self.moved_pic = cv2.warpAffine(self.pic, M, (width, height))
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg',self.moved_pic)
+ cv2.waitKey(0)
+
+ def ImageResizeTimes(self, x_times, y_times):
+ self.moved_pic = cv2.resize(self.pic, (0, 0), fx=x_times, fy=y_times)
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg',self.moved_pic)
+ cv2.waitKey(0)
+
+ def ImageResizePixel(self, x_p, y_p):
+ self.moved_pic = cv2.resize(self.pic, (x_p, y_p))
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg',self.moved_pic)
+ cv2.waitKey(0)
+
+ def HorizentalFlip(self):
+ self.moved_pic = cv2.flip(self.pic, 1, dst=None)
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg',self.moved_pic)
+ cv2.waitKey(0)
+
+ def VerticalFlip(self):
+ self.moved_pic = cv2.flip(self.pic, 0, dst=None)
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg', self.moved_pic)
+ cv2.waitKey(0)
+
+ def CrossFlip(self):
+ self.moved_pic = cv2.flip(self.pic, -1, dst=None)
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg', self.moved_pic)
+ cv2.waitKey(0)
+
+ def FreeRotate(self, angle, size):
+ height, width, channel = self.pic.shape
+ S = cv2.getRotationMatrix2D((width/2, height/2), angle, size)
+ self.moved_pic = cv2.warpAffine(self.pic, S, (width, height))
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg', self.moved_pic)
+ cv2.waitKey(0)
+
+ def FixedRotate(self, mode):
+ if mode == '90':
+ self.moved_pic = cv2.rotate(self.pic, cv2.ROTATE_90_CLOCKWISE)
+ elif mode == '180':
+ self.moved_pic = cv2.rotate(self.pic, cv2.ROTATE_180)
+ elif mode == '270':
+ self.moved_pic = cv2.rotate(self.pic, cv2.ROTATE_90_COUNTERCLOCKWISE)
+
+ cv2.imwrite('img/geometryImgs/moved_pic.jpg', self.moved_pic)
+ cv2.waitKey(0)
+
+
+
+
+
+
+
+
+
+
diff --git a/DILCode/img/EdgeImgs/EdgePic.jpg b/DILCode/img/EdgeImgs/EdgePic.jpg
new file mode 100644
index 0000000..f1fc27e
Binary files /dev/null and b/DILCode/img/EdgeImgs/EdgePic.jpg differ
diff --git a/DILCode/img/colorImgs/Cchannel.jpg b/DILCode/img/colorImgs/Cchannel.jpg
new file mode 100644
index 0000000..25fd254
Binary files /dev/null and b/DILCode/img/colorImgs/Cchannel.jpg differ
diff --git a/DILCode/img/faceImg/facePic.jpg b/DILCode/img/faceImg/facePic.jpg
new file mode 100644
index 0000000..04acbf5
Binary files /dev/null and b/DILCode/img/faceImg/facePic.jpg differ
diff --git a/DILCode/img/filterImgs/FilterPic.jpg b/DILCode/img/filterImgs/FilterPic.jpg
new file mode 100644
index 0000000..a612458
Binary files /dev/null and b/DILCode/img/filterImgs/FilterPic.jpg differ
diff --git a/DILCode/img/geometryImgs/moved_pic.jpg b/DILCode/img/geometryImgs/moved_pic.jpg
new file mode 100644
index 0000000..04acbf5
Binary files /dev/null and b/DILCode/img/geometryImgs/moved_pic.jpg differ
diff --git a/DILCode/img/histogram/histogram.jpg b/DILCode/img/histogram/histogram.jpg
new file mode 100644
index 0000000..567b9e8
Binary files /dev/null and b/DILCode/img/histogram/histogram.jpg differ
diff --git a/DILCode/img/mophologyImgs/mophoPic.jpg b/DILCode/img/mophologyImgs/mophoPic.jpg
new file mode 100644
index 0000000..7eb24be
Binary files /dev/null and b/DILCode/img/mophologyImgs/mophoPic.jpg differ
diff --git a/DILCode/mophologyMenu.py b/DILCode/mophologyMenu.py
new file mode 100644
index 0000000..a5db3db
--- /dev/null
+++ b/DILCode/mophologyMenu.py
@@ -0,0 +1,39 @@
+import math
+import cv2
+import numpy as np
+import struct
+import matplotlib.pyplot as plt
+
+class mophologyMenu:
+
+ def __init__(self, pic_path):
+ self.pic_path = pic_path
+ self.pic = cv2.imread(self.pic_path, 1).astype(np.uint8)
+
+ def ShowPic(self):
+ cv2.imshow('当前图片', self.pic)
+ cv2.waitKey(0) # 0一直显示,直到有键盘输入。也可以是其他数字.
+
+ def Erode(self, constructSize):
+ kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (constructSize, constructSize), (-1, -1))
+ erosion = cv2.erode(self.pic, kernel)
+ cv2.imwrite('img/mophologyImgs/mophoPic.jpg',erosion)
+ cv2.waitKey(0)
+
+ def Dilate(self, constructSize):
+ kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (constructSize, constructSize))
+ dilation = cv2.dilate(self.pic, kernel)
+ cv2.imwrite('img/mophologyImgs/mophoPic.jpg', dilation)
+ cv2.waitKey(0)
+
+ def Open(self, cons):
+ kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (cons, cons))
+ Open = cv2.morphologyEx(self.pic, cv2.MORPH_OPEN, kernel)
+ cv2.imwrite('img/mophologyImgs/mophoPic.jpg', Open)
+ cv2.waitKey(0)
+
+ def Close(self, cons):
+ kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (cons, cons))
+ Close = cv2.morphologyEx(self.pic, cv2.MORPH_CLOSE, kernel)
+ cv2.imwrite('img/mophologyImgs/mophoPic.jpg', Close)
+ cv2.waitKey(0)
\ No newline at end of file
diff --git a/DILCode/ui_file_1.py b/DILCode/ui_file_1.py
new file mode 100644
index 0000000..d98cb5c
--- /dev/null
+++ b/DILCode/ui_file_1.py
@@ -0,0 +1,449 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'ui_file_1.ui'
+#
+# Created by: PyQt5 UI code generator 5.15.7
+#
+# WARNING: Any manual changes made to this file will be lost when pyuic5 is
+# run again. Do not edit this file unless you know what you are doing.
+
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+
+class Ui_mainWindow(object):
+ def setupUi(self, mainWindow):
+ mainWindow.setObjectName("mainWindow")
+ mainWindow.resize(729, 526)
+ mainWindow.setStyleSheet("QLabel { \n"
+" color:#5c4033 ;\n"
+" font-size:16px;\n"
+" border:0px solid #b5a642;\n"
+" font-family:幼圆;\n"
+" background-color: silver\n"
+"}\n"
+"\n"
+"QGroupBox {\n"
+" font-family:幼圆;\n"
+" font-size:16px;\n"
+"}\n"
+"\n"
+"QPushButton {\n"
+" border: 1px solid rgb(124, 124, 124);\n"
+" background-color: qconicalgradient(cx:0.5, cy:0.5, angle:180, stop:0.49999 rgba(214, 214, 214, 255), stop:0.50001 rgba(236, 236, 236, 255)); \n"
+" border-radius:30px;\n"
+" font-family:微软雅黑;\n"
+" font-size:25px;\n"
+"}\n"
+"\n"
+"QPushButton:hover{\n"
+" border: 1px solid #3C80B1;\n"
+" background-color: qconicalgradient(cx:0.5, cy:0.5, angle:180, stop:0.49999 rgba(181, 225, 250, 255), stop:0.50001 rgba(222, 242, 251, 255));\n"
+" border-radius:5px;\n"
+"}\n"
+"\n"
+"QPushButton:pressed{\n"
+" border: 1px solid #5F92B2;\n"
+" background-color: qconicalgradient(cx:0.5, cy:0.5, angle:180, stop:0.49999 rgba(134, 198, 233, 255), stop:0.50001 rgba(206, 234, 248, 255));\n"
+" border-radius:5px;\n"
+"}")
+ self.centralwidget = QtWidgets.QWidget(mainWindow)
+ self.centralwidget.setObjectName("centralwidget")
+ self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.horizontalLayout = QtWidgets.QHBoxLayout()
+ self.horizontalLayout.setContentsMargins(-1, -1, -1, 10)
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.original_group = QtWidgets.QGroupBox(self.centralwidget)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.original_group.sizePolicy().hasHeightForWidth())
+ self.original_group.setSizePolicy(sizePolicy)
+ font = QtGui.QFont()
+ font.setFamily("幼圆")
+ font.setPointSize(-1)
+ self.original_group.setFont(font)
+ self.original_group.setObjectName("original_group")
+ self.gridLayout_2 = QtWidgets.QGridLayout(self.original_group)
+ self.gridLayout_2.setObjectName("gridLayout_2")
+ self.ori_pic = QtWidgets.QLabel(self.original_group)
+ self.ori_pic.setText("")
+ self.ori_pic.setScaledContents(True)
+ self.ori_pic.setObjectName("ori_pic")
+ self.gridLayout_2.addWidget(self.ori_pic, 0, 0, 1, 1)
+ self.horizontalLayout.addWidget(self.original_group)
+ self.fixed_group = QtWidgets.QGroupBox(self.centralwidget)
+ font = QtGui.QFont()
+ font.setFamily("幼圆")
+ font.setPointSize(-1)
+ self.fixed_group.setFont(font)
+ self.fixed_group.setMouseTracking(False)
+ self.fixed_group.setObjectName("fixed_group")
+ self.gridLayout = QtWidgets.QGridLayout(self.fixed_group)
+ self.gridLayout.setObjectName("gridLayout")
+ self.fixed_pic = QtWidgets.QLabel(self.fixed_group)
+ self.fixed_pic.setText("")
+ self.fixed_pic.setScaledContents(True)
+ self.fixed_pic.setObjectName("fixed_pic")
+ self.gridLayout.addWidget(self.fixed_pic, 0, 0, 1, 1)
+ self.horizontalLayout.addWidget(self.fixed_group)
+ self.horizontalLayout.setStretch(0, 1)
+ self.horizontalLayout.setStretch(1, 1)
+ self.verticalLayout.addLayout(self.horizontalLayout)
+ self.gridLayout_4 = QtWidgets.QGridLayout()
+ self.gridLayout_4.setContentsMargins(-1, -1, -1, 10)
+ self.gridLayout_4.setObjectName("gridLayout_4")
+ self.origin_label = QtWidgets.QLabel(self.centralwidget)
+ self.origin_label.setAlignment(QtCore.Qt.AlignCenter)
+ self.origin_label.setObjectName("origin_label")
+ self.gridLayout_4.addWidget(self.origin_label, 0, 0, 1, 1)
+ self.origin_pic_path = QtWidgets.QLabel(self.centralwidget)
+ font = QtGui.QFont()
+ font.setFamily("幼圆")
+ font.setPointSize(-1)
+ self.origin_pic_path.setFont(font)
+ self.origin_pic_path.setAlignment(QtCore.Qt.AlignCenter)
+ self.origin_pic_path.setObjectName("origin_pic_path")
+ self.gridLayout_4.addWidget(self.origin_pic_path, 0, 1, 1, 1)
+ self.gridLayout_4.setColumnStretch(0, 1)
+ self.gridLayout_4.setColumnStretch(1, 3)
+ self.verticalLayout.addLayout(self.gridLayout_4)
+ self.gridLayout_3 = QtWidgets.QGridLayout()
+ self.gridLayout_3.setContentsMargins(-1, -1, -1, 10)
+ self.gridLayout_3.setObjectName("gridLayout_3")
+ self.save_label = QtWidgets.QLabel(self.centralwidget)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.save_label.sizePolicy().hasHeightForWidth())
+ self.save_label.setSizePolicy(sizePolicy)
+ self.save_label.setAlignment(QtCore.Qt.AlignCenter)
+ self.save_label.setObjectName("save_label")
+ self.gridLayout_3.addWidget(self.save_label, 0, 0, 1, 1)
+ self.save_pic_path = QtWidgets.QLabel(self.centralwidget)
+ self.save_pic_path.setAlignment(QtCore.Qt.AlignCenter)
+ self.save_pic_path.setObjectName("save_pic_path")
+ self.gridLayout_3.addWidget(self.save_pic_path, 0, 1, 1, 1)
+ self.gridLayout_3.setColumnStretch(0, 1)
+ self.gridLayout_3.setColumnStretch(1, 3)
+ self.verticalLayout.addLayout(self.gridLayout_3)
+ self.verticalLayout.setStretch(0, 10)
+ self.verticalLayout.setStretch(1, 1)
+ mainWindow.setCentralWidget(self.centralwidget)
+ self.menubar = QtWidgets.QMenuBar(mainWindow)
+ self.menubar.setEnabled(True)
+ self.menubar.setGeometry(QtCore.QRect(0, 0, 729, 23))
+ self.menubar.setCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
+ self.menubar.setObjectName("menubar")
+ self.file_menu = QtWidgets.QMenu(self.menubar)
+ self.file_menu.setEnabled(True)
+ self.file_menu.setObjectName("file_menu")
+ self.geo_menu = QtWidgets.QMenu(self.menubar)
+ self.geo_menu.setEnabled(True)
+ self.geo_menu.setObjectName("geo_menu")
+ self.RotateMenu = QtWidgets.QMenu(self.geo_menu)
+ self.RotateMenu.setObjectName("RotateMenu")
+ self.denoising_menu = QtWidgets.QMenu(self.menubar)
+ self.denoising_menu.setEnabled(True)
+ self.denoising_menu.setObjectName("denoising_menu")
+ self.Noise_menu = QtWidgets.QMenu(self.denoising_menu)
+ self.Noise_menu.setObjectName("Noise_menu")
+ self.Filter_menu = QtWidgets.QMenu(self.denoising_menu)
+ self.Filter_menu.setObjectName("Filter_menu")
+ self.Statistic_Filtering_menu = QtWidgets.QMenu(self.Filter_menu)
+ self.Statistic_Filtering_menu.setObjectName("Statistic_Filtering_menu")
+ self.Choice_menu = QtWidgets.QMenu(self.Filter_menu)
+ self.Choice_menu.setObjectName("Choice_menu")
+ self.color_menu = QtWidgets.QMenu(self.menubar)
+ self.color_menu.setObjectName("color_menu")
+ self.menuRGB = QtWidgets.QMenu(self.color_menu)
+ self.menuRGB.setObjectName("menuRGB")
+ self.menuHSV = QtWidgets.QMenu(self.color_menu)
+ self.menuHSV.setObjectName("menuHSV")
+ self.histogram_menu = QtWidgets.QMenu(self.menubar)
+ self.histogram_menu.setObjectName("histogram_menu")
+ self.advancecd_menu = QtWidgets.QMenu(self.menubar)
+ self.advancecd_menu.setObjectName("advancecd_menu")
+ self.edge_menu = QtWidgets.QMenu(self.advancecd_menu)
+ self.edge_menu.setObjectName("edge_menu")
+ self.menuHough = QtWidgets.QMenu(self.advancecd_menu)
+ self.menuHough.setObjectName("menuHough")
+ self.mophology_menu = QtWidgets.QMenu(self.menubar)
+ self.mophology_menu.setObjectName("mophology_menu")
+ self.faceMenu = QtWidgets.QMenu(self.menubar)
+ self.faceMenu.setObjectName("faceMenu")
+ self.videoMenu = QtWidgets.QMenu(self.menubar)
+ self.videoMenu.setObjectName("videoMenu")
+ mainWindow.setMenuBar(self.menubar)
+ self.statusbar = QtWidgets.QStatusBar(mainWindow)
+ self.statusbar.setObjectName("statusbar")
+ mainWindow.setStatusBar(self.statusbar)
+ self.Mirror_H_menu = QtWidgets.QAction(mainWindow)
+ self.Mirror_H_menu.setObjectName("Mirror_H_menu")
+ self.Mirror_V_menu = QtWidgets.QAction(mainWindow)
+ self.Mirror_V_menu.setObjectName("Mirror_V_menu")
+ self.Histogram_Equalization2_menu = QtWidgets.QAction(mainWindow)
+ self.Histogram_Equalization2_menu.setObjectName("Histogram_Equalization2_menu")
+ self.Histogram_Equalization_menu = QtWidgets.QAction(mainWindow)
+ self.Histogram_Equalization_menu.setObjectName("Histogram_Equalization_menu")
+ self.Salt_And_Pepper_Noise_menu = QtWidgets.QAction(mainWindow)
+ self.Salt_And_Pepper_Noise_menu.setObjectName("Salt_And_Pepper_Noise_menu")
+ self.Gauss_Noise_menu = QtWidgets.QAction(mainWindow)
+ self.Gauss_Noise_menu.setObjectName("Gauss_Noise_menu")
+ self.Gaussian_Blur_menu = QtWidgets.QAction(mainWindow)
+ self.Gaussian_Blur_menu.setObjectName("Gaussian_Blur_menu")
+ self.Average_Filtering_menu = QtWidgets.QAction(mainWindow)
+ self.Average_Filtering_menu.setObjectName("Average_Filtering_menu")
+ self.grey_info = QtWidgets.QAction(mainWindow)
+ self.grey_info.setObjectName("grey_info")
+ self.Open_btn = QtWidgets.QAction(mainWindow)
+ self.Open_btn.setObjectName("Open_btn")
+ self.ImageResize_t = QtWidgets.QAction(mainWindow)
+ self.ImageResize_t.setObjectName("ImageResize_t")
+ self.ImageResize_p = QtWidgets.QAction(mainWindow)
+ self.ImageResize_p.setObjectName("ImageResize_p")
+ self.ImageMove = QtWidgets.QAction(mainWindow)
+ self.ImageMove.setObjectName("ImageMove")
+ self.extractB = QtWidgets.QAction(mainWindow)
+ self.extractB.setObjectName("extractB")
+ self.extractG = QtWidgets.QAction(mainWindow)
+ self.extractG.setObjectName("extractG")
+ self.extractR = QtWidgets.QAction(mainWindow)
+ self.extractR.setObjectName("extractR")
+ self.extractH = QtWidgets.QAction(mainWindow)
+ self.extractH.setObjectName("extractH")
+ self.extractS = QtWidgets.QAction(mainWindow)
+ self.extractS.setObjectName("extractS")
+ self.extractV = QtWidgets.QAction(mainWindow)
+ self.extractV.setObjectName("extractV")
+ self.Mirror_C_menu = QtWidgets.QAction(mainWindow)
+ self.Mirror_C_menu.setObjectName("Mirror_C_menu")
+ self.GreyHistogram = QtWidgets.QAction(mainWindow)
+ self.GreyHistogram.setObjectName("GreyHistogram")
+ self.ColorHistogram = QtWidgets.QAction(mainWindow)
+ self.ColorHistogram.setObjectName("ColorHistogram")
+ self.ImageEnhance = QtWidgets.QAction(mainWindow)
+ self.ImageEnhance.setObjectName("ImageEnhance")
+ self.RobertsOperator = QtWidgets.QAction(mainWindow)
+ self.RobertsOperator.setObjectName("RobertsOperator")
+ self.SobelOperator = QtWidgets.QAction(mainWindow)
+ self.SobelOperator.setObjectName("SobelOperator")
+ self.LaplacianOperator = QtWidgets.QAction(mainWindow)
+ self.LaplacianOperator.setObjectName("LaplacianOperator")
+ self.LoGOperator = QtWidgets.QAction(mainWindow)
+ self.LoGOperator.setObjectName("LoGOperator")
+ self.actionCanny = QtWidgets.QAction(mainWindow)
+ self.actionCanny.setObjectName("actionCanny")
+ self.Erosion = QtWidgets.QAction(mainWindow)
+ self.Erosion.setObjectName("Erosion")
+ self.Inflation = QtWidgets.QAction(mainWindow)
+ self.Inflation.setObjectName("Inflation")
+ self.OpenOperation = QtWidgets.QAction(mainWindow)
+ self.OpenOperation.setObjectName("OpenOperation")
+ self.CloseOperation = QtWidgets.QAction(mainWindow)
+ self.CloseOperation.setObjectName("CloseOperation")
+ self.Save_btn = QtWidgets.QAction(mainWindow)
+ self.Save_btn.setObjectName("Save_btn")
+ self.FreeRotation = QtWidgets.QAction(mainWindow)
+ self.FreeRotation.setObjectName("FreeRotation")
+ self.FixedRotation = QtWidgets.QAction(mainWindow)
+ self.FixedRotation.setObjectName("FixedRotation")
+ self.leastFilter = QtWidgets.QAction(mainWindow)
+ self.leastFilter.setObjectName("leastFilter")
+ self.middleFilter = QtWidgets.QAction(mainWindow)
+ self.middleFilter.setObjectName("middleFilter")
+ self.LargestFilter = QtWidgets.QAction(mainWindow)
+ self.LargestFilter.setObjectName("LargestFilter")
+ self.passFilter = QtWidgets.QAction(mainWindow)
+ self.passFilter.setObjectName("passFilter")
+ self.blockFilter = QtWidgets.QAction(mainWindow)
+ self.blockFilter.setObjectName("blockFilter")
+ self.faceDetection = QtWidgets.QAction(mainWindow)
+ self.faceDetection.setObjectName("faceDetection")
+ self.StraightDetect = QtWidgets.QAction(mainWindow)
+ self.StraightDetect.setObjectName("StraightDetect")
+ self.CurveDetect = QtWidgets.QAction(mainWindow)
+ self.CurveDetect.setObjectName("CurveDetect")
+ self.videoDetkt = QtWidgets.QAction(mainWindow)
+ self.videoDetkt.setObjectName("videoDetkt")
+ self.file_menu.addAction(self.Open_btn)
+ self.file_menu.addAction(self.Save_btn)
+ self.RotateMenu.addSeparator()
+ self.RotateMenu.addAction(self.FreeRotation)
+ self.RotateMenu.addAction(self.FixedRotation)
+ self.geo_menu.addAction(self.ImageMove)
+ self.geo_menu.addAction(self.ImageResize_t)
+ self.geo_menu.addAction(self.ImageResize_p)
+ self.geo_menu.addAction(self.Mirror_H_menu)
+ self.geo_menu.addAction(self.Mirror_V_menu)
+ self.geo_menu.addAction(self.Mirror_C_menu)
+ self.geo_menu.addAction(self.RotateMenu.menuAction())
+ self.Noise_menu.addAction(self.Salt_And_Pepper_Noise_menu)
+ self.Noise_menu.addAction(self.Gauss_Noise_menu)
+ self.Statistic_Filtering_menu.addSeparator()
+ self.Statistic_Filtering_menu.addAction(self.leastFilter)
+ self.Statistic_Filtering_menu.addAction(self.middleFilter)
+ self.Statistic_Filtering_menu.addAction(self.LargestFilter)
+ self.Choice_menu.addAction(self.passFilter)
+ self.Choice_menu.addAction(self.blockFilter)
+ self.Filter_menu.addAction(self.Gaussian_Blur_menu)
+ self.Filter_menu.addAction(self.Average_Filtering_menu)
+ self.Filter_menu.addAction(self.Statistic_Filtering_menu.menuAction())
+ self.Filter_menu.addAction(self.Choice_menu.menuAction())
+ self.denoising_menu.addAction(self.Noise_menu.menuAction())
+ self.denoising_menu.addAction(self.Filter_menu.menuAction())
+ self.menuRGB.addAction(self.extractB)
+ self.menuRGB.addAction(self.extractG)
+ self.menuRGB.addAction(self.extractR)
+ self.menuHSV.addAction(self.extractH)
+ self.menuHSV.addAction(self.extractS)
+ self.menuHSV.addAction(self.extractV)
+ self.color_menu.addAction(self.menuRGB.menuAction())
+ self.color_menu.addAction(self.menuHSV.menuAction())
+ self.color_menu.addAction(self.grey_info)
+ self.histogram_menu.addAction(self.GreyHistogram)
+ self.histogram_menu.addAction(self.ColorHistogram)
+ self.edge_menu.addAction(self.RobertsOperator)
+ self.edge_menu.addAction(self.SobelOperator)
+ self.edge_menu.addAction(self.LaplacianOperator)
+ self.edge_menu.addAction(self.LoGOperator)
+ self.edge_menu.addAction(self.actionCanny)
+ self.menuHough.addSeparator()
+ self.menuHough.addAction(self.StraightDetect)
+ self.menuHough.addAction(self.CurveDetect)
+ self.advancecd_menu.addAction(self.ImageEnhance)
+ self.advancecd_menu.addAction(self.edge_menu.menuAction())
+ self.advancecd_menu.addAction(self.menuHough.menuAction())
+ self.mophology_menu.addAction(self.Erosion)
+ self.mophology_menu.addAction(self.Inflation)
+ self.mophology_menu.addAction(self.OpenOperation)
+ self.mophology_menu.addAction(self.CloseOperation)
+ self.faceMenu.addAction(self.faceDetection)
+ self.videoMenu.addAction(self.videoDetkt)
+ self.menubar.addAction(self.file_menu.menuAction())
+ self.menubar.addAction(self.color_menu.menuAction())
+ self.menubar.addAction(self.geo_menu.menuAction())
+ self.menubar.addAction(self.histogram_menu.menuAction())
+ self.menubar.addAction(self.mophology_menu.menuAction())
+ self.menubar.addAction(self.advancecd_menu.menuAction())
+ self.menubar.addAction(self.denoising_menu.menuAction())
+ self.menubar.addAction(self.faceMenu.menuAction())
+ self.menubar.addAction(self.videoMenu.menuAction())
+
+ self.retranslateUi(mainWindow)
+ self.Open_btn.triggered.connect(mainWindow.OpenImg) # type: ignore
+ self.Save_btn.triggered.connect(mainWindow.SaveImg) # type: ignore
+ self.extractV.triggered.connect(mainWindow.ExtractVchannel) # type: ignore
+ self.extractS.triggered.connect(mainWindow.ExtractSchannel) # type: ignore
+ self.extractH.triggered.connect(mainWindow.ExtractHchannel) # type: ignore
+ self.extractR.triggered.connect(mainWindow.ExtractRchannel) # type: ignore
+ self.extractG.triggered.connect(mainWindow.ExtractGchannel) # type: ignore
+ self.extractB.triggered.connect(mainWindow.ExtractBchannel) # type: ignore
+ self.grey_info.triggered.connect(mainWindow.GreyPic) # type: ignore
+ self.ImageMove.triggered.connect(mainWindow.MovePic) # type: ignore
+ self.ImageResize_t.triggered.connect(mainWindow.ImageResizeTimes) # type: ignore
+ self.ImageResize_p.triggered.connect(mainWindow.ImageResizePixel) # type: ignore
+ self.Mirror_H_menu.triggered.connect(mainWindow.HorizontalFlip) # type: ignore
+ self.Mirror_V_menu.triggered.connect(mainWindow.VerticalFlip) # type: ignore
+ self.Mirror_C_menu.triggered.connect(mainWindow.CrossFlip) # type: ignore
+ self.FreeRotation.triggered.connect(mainWindow.FreeRotate) # type: ignore
+ self.FixedRotation.triggered.connect(mainWindow.FixedRotate) # type: ignore
+ self.GreyHistogram.triggered.connect(mainWindow.DrawGreyHistogram) # type: ignore
+ self.ColorHistogram.triggered.connect(mainWindow.DrawRGBHistogram) # type: ignore
+ self.Erosion.triggered.connect(mainWindow.Erode) # type: ignore
+ self.Inflation.triggered.connect(mainWindow.Dilate) # type: ignore
+ self.OpenOperation.triggered.connect(mainWindow.OpenOperate) # type: ignore
+ self.CloseOperation.triggered.connect(mainWindow.CloseOperate) # type: ignore
+ self.ImageEnhance.triggered.connect(mainWindow.PicStrength) # type: ignore
+ self.RobertsOperator.triggered.connect(mainWindow.RobertsOperation) # type: ignore
+ self.SobelOperator.triggered.connect(mainWindow.SobelOperation) # type: ignore
+ self.LaplacianOperator.triggered.connect(mainWindow.LaplacianOperation) # type: ignore
+ self.LoGOperator.triggered.connect(mainWindow.LoGOperation) # type: ignore
+ self.actionCanny.triggered.connect(mainWindow.CannyOperation) # type: ignore
+ self.Gauss_Noise_menu.triggered.connect(mainWindow.GaussNoise) # type: ignore
+ self.Salt_And_Pepper_Noise_menu.triggered.connect(mainWindow.PepperSaltyNoise) # type: ignore
+ self.Gaussian_Blur_menu.triggered.connect(mainWindow.GaussFilter) # type: ignore
+ self.Average_Filtering_menu.triggered.connect(mainWindow.AvgFilter) # type: ignore
+ self.leastFilter.triggered.connect(mainWindow.minFilter) # type: ignore
+ self.middleFilter.triggered.connect(mainWindow.MidFilter) # type: ignore
+ self.LargestFilter.triggered.connect(mainWindow.maxFilter) # type: ignore
+ self.passFilter.triggered.connect(mainWindow.PassFilter) # type: ignore
+ self.blockFilter.triggered.connect(mainWindow.BlockFilter) # type: ignore
+ self.faceDetection.triggered.connect(mainWindow.faceDetect) # type: ignore
+ self.StraightDetect.triggered.connect(mainWindow.HoughStraight) # type: ignore
+ self.CurveDetect.triggered.connect(mainWindow.HoughCurve) # type: ignore
+ self.videoDetkt.triggered.connect(mainWindow.videoDetect) # type: ignore
+ QtCore.QMetaObject.connectSlotsByName(mainWindow)
+
+ def retranslateUi(self, mainWindow):
+ _translate = QtCore.QCoreApplication.translate
+ mainWindow.setWindowTitle(_translate("mainWindow", "数字图像处理 By 图图"))
+ self.original_group.setTitle(_translate("mainWindow", "原始图片"))
+ self.fixed_group.setTitle(_translate("mainWindow", "处理图片"))
+ self.origin_label.setText(_translate("mainWindow", "原始图片路径:"))
+ self.origin_pic_path.setText(_translate("mainWindow", "尚未选中图片"))
+ self.save_label.setText(_translate("mainWindow", " 图片缓存路径: "))
+ self.save_pic_path.setText(_translate("mainWindow", "默认保存在img文件夹"))
+ self.file_menu.setTitle(_translate("mainWindow", "文件"))
+ self.geo_menu.setTitle(_translate("mainWindow", "几何变换"))
+ self.RotateMenu.setTitle(_translate("mainWindow", "图像旋转"))
+ self.denoising_menu.setTitle(_translate("mainWindow", "图像去噪相关"))
+ self.Noise_menu.setTitle(_translate("mainWindow", "随机给图片添加噪声"))
+ self.Filter_menu.setTitle(_translate("mainWindow", "图像滤波"))
+ self.Statistic_Filtering_menu.setTitle(_translate("mainWindow", "排序统计类滤波"))
+ self.Choice_menu.setTitle(_translate("mainWindow", "选择性滤波器"))
+ self.color_menu.setTitle(_translate("mainWindow", "色彩空间"))
+ self.menuRGB.setTitle(_translate("mainWindow", "RGB空间"))
+ self.menuHSV.setTitle(_translate("mainWindow", "HSV空间"))
+ self.histogram_menu.setTitle(_translate("mainWindow", "直方图"))
+ self.advancecd_menu.setTitle(_translate("mainWindow", "图像进阶操作"))
+ self.edge_menu.setTitle(_translate("mainWindow", "边缘检测"))
+ self.menuHough.setTitle(_translate("mainWindow", "Hough线条变化检测"))
+ self.mophology_menu.setTitle(_translate("mainWindow", "形态学操作"))
+ self.faceMenu.setTitle(_translate("mainWindow", "人脸识别"))
+ self.videoMenu.setTitle(_translate("mainWindow", "视频人脸识别"))
+ self.Mirror_H_menu.setText(_translate("mainWindow", "水平镜像"))
+ self.Mirror_V_menu.setText(_translate("mainWindow", "垂直镜像"))
+ self.Histogram_Equalization2_menu.setText(_translate("mainWindow", "三个通道分别均衡化"))
+ self.Histogram_Equalization_menu.setText(_translate("mainWindow", "三个通道一起均衡化(不推荐)"))
+ self.Salt_And_Pepper_Noise_menu.setText(_translate("mainWindow", "椒盐噪声"))
+ self.Gauss_Noise_menu.setText(_translate("mainWindow", "高斯噪声"))
+ self.Gaussian_Blur_menu.setText(_translate("mainWindow", "Gauss滤波"))
+ self.Average_Filtering_menu.setText(_translate("mainWindow", "算术均值滤波"))
+ self.grey_info.setText(_translate("mainWindow", "图片灰度化"))
+ self.Open_btn.setText(_translate("mainWindow", "打开图片"))
+ self.ImageResize_t.setText(_translate("mainWindow", "图像放缩(倍率)"))
+ self.ImageResize_p.setText(_translate("mainWindow", "图像放缩(定值)"))
+ self.ImageMove.setText(_translate("mainWindow", "图像平移"))
+ self.extractB.setText(_translate("mainWindow", "B通道提取"))
+ self.extractG.setText(_translate("mainWindow", "G通道提取"))
+ self.extractR.setText(_translate("mainWindow", "R通道提取"))
+ self.extractH.setText(_translate("mainWindow", "H通道提取"))
+ self.extractS.setText(_translate("mainWindow", "S通道提取"))
+ self.extractV.setText(_translate("mainWindow", "V通道提取"))
+ self.Mirror_C_menu.setText(_translate("mainWindow", "对角镜像"))
+ self.GreyHistogram.setText(_translate("mainWindow", "绘制灰度直方图"))
+ self.ColorHistogram.setText(_translate("mainWindow", "绘制彩色直方图"))
+ self.ImageEnhance.setText(_translate("mainWindow", "图像增强"))
+ self.RobertsOperator.setText(_translate("mainWindow", "Roberts算子"))
+ self.SobelOperator.setText(_translate("mainWindow", "Sobel算子"))
+ self.LaplacianOperator.setText(_translate("mainWindow", "Laplacian 算子"))
+ self.LoGOperator.setText(_translate("mainWindow", "LoG 边缘算子"))
+ self.actionCanny.setText(_translate("mainWindow", "Canny 边缘检测"))
+ self.Erosion.setText(_translate("mainWindow", "腐蚀"))
+ self.Inflation.setText(_translate("mainWindow", "膨胀"))
+ self.OpenOperation.setText(_translate("mainWindow", "开运算"))
+ self.CloseOperation.setText(_translate("mainWindow", "闭运算"))
+ self.Save_btn.setText(_translate("mainWindow", "保存图片"))
+ self.FreeRotation.setText(_translate("mainWindow", "自由旋转"))
+ self.FixedRotation.setText(_translate("mainWindow", "垂直旋转"))
+ self.leastFilter.setText(_translate("mainWindow", "最小值滤波"))
+ self.middleFilter.setText(_translate("mainWindow", "中值滤波"))
+ self.LargestFilter.setText(_translate("mainWindow", "最大值滤波"))
+ self.passFilter.setText(_translate("mainWindow", "带通滤波"))
+ self.blockFilter.setText(_translate("mainWindow", "带阻滤波"))
+ self.faceDetection.setText(_translate("mainWindow", "图像人脸识别"))
+ self.StraightDetect.setText(_translate("mainWindow", "直线检测"))
+ self.CurveDetect.setText(_translate("mainWindow", "曲线检测"))
+ self.videoDetkt.setText(_translate("mainWindow", "实时人脸识别"))
diff --git a/DILCode/ui_file_1.ui b/DILCode/ui_file_1.ui
new file mode 100644
index 0000000..59e6045
--- /dev/null
+++ b/DILCode/ui_file_1.ui
@@ -0,0 +1,1305 @@
+
+
+ mainWindow
+
+
+
+ 0
+ 0
+ 729
+ 526
+
+
+
+ 数字图像处理 By 图图
+
+
+ QLabel {
+ color:#5c4033 ;
+ font-size:16px;
+ border:0px solid #b5a642;
+ font-family:幼圆;
+ background-color: silver
+}
+
+QGroupBox {
+ font-family:幼圆;
+ font-size:16px;
+}
+
+QPushButton {
+ border: 1px solid rgb(124, 124, 124);
+ background-color: qconicalgradient(cx:0.5, cy:0.5, angle:180, stop:0.49999 rgba(214, 214, 214, 255), stop:0.50001 rgba(236, 236, 236, 255));
+ border-radius:30px;
+ font-family:微软雅黑;
+ font-size:25px;
+}
+
+QPushButton:hover{
+ border: 1px solid #3C80B1;
+ background-color: qconicalgradient(cx:0.5, cy:0.5, angle:180, stop:0.49999 rgba(181, 225, 250, 255), stop:0.50001 rgba(222, 242, 251, 255));
+ border-radius:5px;
+}
+
+QPushButton:pressed{
+ border: 1px solid #5F92B2;
+ background-color: qconicalgradient(cx:0.5, cy:0.5, angle:180, stop:0.49999 rgba(134, 198, 233, 255), stop:0.50001 rgba(206, 234, 248, 255));
+ border-radius:5px;
+}
+
+
+
+ -
+
+
+ 10
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 幼圆
+ -1
+
+
+
+ 原始图片
+
+
+
-
+
+
+
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+
+ 幼圆
+ -1
+
+
+
+ false
+
+
+ 处理图片
+
+
+
-
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+ -
+
+
+ 10
+
+
-
+
+
+ 原始图片路径:
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 幼圆
+ -1
+
+
+
+ 尚未选中图片
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
+ 10
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ 图片缓存路径:
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ 默认保存在img文件夹
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+
+
+
+
+
+ 水平镜像
+
+
+
+
+ 垂直镜像
+
+
+
+
+ 三个通道分别均衡化
+
+
+
+
+ 三个通道一起均衡化(不推荐)
+
+
+
+
+ 椒盐噪声
+
+
+
+
+ 高斯噪声
+
+
+
+
+ Gauss滤波
+
+
+
+
+ 算术均值滤波
+
+
+
+
+ 图片灰度化
+
+
+
+
+ 打开图片
+
+
+
+
+ 图像放缩(倍率)
+
+
+
+
+ 图像放缩(定值)
+
+
+
+
+ 图像平移
+
+
+
+
+ B通道提取
+
+
+
+
+ G通道提取
+
+
+
+
+ R通道提取
+
+
+
+
+ H通道提取
+
+
+
+
+ S通道提取
+
+
+
+
+ V通道提取
+
+
+
+
+ 对角镜像
+
+
+
+
+ 绘制灰度直方图
+
+
+
+
+ 绘制彩色直方图
+
+
+
+
+ 图像增强
+
+
+
+
+ Roberts算子
+
+
+
+
+ Sobel算子
+
+
+
+
+ Laplacian 算子
+
+
+
+
+ LoG 边缘算子
+
+
+
+
+ Canny 边缘检测
+
+
+
+
+ 腐蚀
+
+
+
+
+ 膨胀
+
+
+
+
+ 开运算
+
+
+
+
+ 闭运算
+
+
+
+
+ 保存图片
+
+
+
+
+ 自由旋转
+
+
+
+
+ 垂直旋转
+
+
+
+
+ 最小值滤波
+
+
+
+
+ 中值滤波
+
+
+
+
+ 最大值滤波
+
+
+
+
+ 带通滤波
+
+
+
+
+ 带阻滤波
+
+
+
+
+ 图像人脸识别
+
+
+
+
+ 直线检测
+
+
+
+
+ 曲线检测
+
+
+
+
+ 实时人脸识别
+
+
+
+
+
+
+ Open_btn
+ triggered()
+ mainWindow
+ OpenImg()
+
+
+ -1
+ -1
+
+
+ 369
+ 281
+
+
+
+
+ Save_btn
+ triggered()
+ mainWindow
+ SaveImg()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ extractV
+ triggered()
+ mainWindow
+ ExtractVchannel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ extractS
+ triggered()
+ mainWindow
+ ExtractSchannel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ extractH
+ triggered()
+ mainWindow
+ ExtractHchannel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ extractR
+ triggered()
+ mainWindow
+ ExtractRchannel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ extractG
+ triggered()
+ mainWindow
+ ExtractGchannel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ extractB
+ triggered()
+ mainWindow
+ ExtractBchannel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ grey_info
+ triggered()
+ mainWindow
+ GreyPic()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ ImageMove
+ triggered()
+ mainWindow
+ MovePic()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ ImageResize_t
+ triggered()
+ mainWindow
+ ImageResizeTimes()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ ImageResize_p
+ triggered()
+ mainWindow
+ ImageResizePixel()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ Mirror_H_menu
+ triggered()
+ mainWindow
+ HorizontalFlip()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ Mirror_V_menu
+ triggered()
+ mainWindow
+ VerticalFlip()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ Mirror_C_menu
+ triggered()
+ mainWindow
+ CrossFlip()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ FreeRotation
+ triggered()
+ mainWindow
+ FreeRotate()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ FixedRotation
+ triggered()
+ mainWindow
+ FixedRotate()
+
+
+ -1
+ -1
+
+
+ 378
+ 262
+
+
+
+
+ GreyHistogram
+ triggered()
+ mainWindow
+ DrawGreyHistogram()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ ColorHistogram
+ triggered()
+ mainWindow
+ DrawRGBHistogram()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ Erosion
+ triggered()
+ mainWindow
+ Erode()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ Inflation
+ triggered()
+ mainWindow
+ Dilate()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ OpenOperation
+ triggered()
+ mainWindow
+ OpenOperate()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ CloseOperation
+ triggered()
+ mainWindow
+ CloseOperate()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ ImageEnhance
+ triggered()
+ mainWindow
+ PicStrength()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ RobertsOperator
+ triggered()
+ mainWindow
+ RobertsOperation()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ SobelOperator
+ triggered()
+ mainWindow
+ SobelOperation()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ LaplacianOperator
+ triggered()
+ mainWindow
+ LaplacianOperation()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ LoGOperator
+ triggered()
+ mainWindow
+ LoGOperation()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ actionCanny
+ triggered()
+ mainWindow
+ CannyOperation()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ Gauss_Noise_menu
+ triggered()
+ mainWindow
+ GaussNoise()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ Salt_And_Pepper_Noise_menu
+ triggered()
+ mainWindow
+ PepperSaltyNoise()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ Gaussian_Blur_menu
+ triggered()
+ mainWindow
+ GaussFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ Average_Filtering_menu
+ triggered()
+ mainWindow
+ AvgFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ leastFilter
+ triggered()
+ mainWindow
+ minFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ middleFilter
+ triggered()
+ mainWindow
+ MidFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ LargestFilter
+ triggered()
+ mainWindow
+ maxFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ passFilter
+ triggered()
+ mainWindow
+ PassFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ blockFilter
+ triggered()
+ mainWindow
+ BlockFilter()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ faceDetection
+ triggered()
+ mainWindow
+ faceDetect()
+
+
+ -1
+ -1
+
+
+ 298
+ 262
+
+
+
+
+ StraightDetect
+ triggered()
+ mainWindow
+ HoughStraight()
+
+
+ 456
+ 83
+
+
+ 364
+ 262
+
+
+
+
+ CurveDetect
+ triggered()
+ mainWindow
+ HoughCurve()
+
+
+ 456
+ 67
+
+
+ 364
+ 262
+
+
+
+
+ videoDetkt
+ triggered()
+ mainWindow
+ videoDetect()
+
+
+ -1
+ -1
+
+
+ 364
+ 262
+
+
+
+
+
+ OpenImg()
+ SaveImg()
+ GreyPic()
+ ExtractBchannel()
+ ExtractGchannel()
+ ExtractRchannel()
+ ExtractHchannel()
+ ExtractSchannel()
+ ExtractVchannel()
+ MovePic()
+ ImageResizeTimes()
+ ImageResizePixel()
+ HorizontalFlip()
+ VerticalFlip()
+ CrossFlip()
+ FreeRotate()
+ FixedRotate()
+ DrawGreyHistogram()
+ DrawRGBHistogram()
+ Erode()
+ Dilate()
+ OpenOperate()
+ CloseOperate()
+ PicStrength()
+ RobertsOperation()
+ SobelOperation()
+ LaplacianOperation()
+ LoGOperation()
+ CannyOperation()
+ GaussNoise()
+ PepperSaltyNoise()
+ GaussFilter()
+ AvgFilter()
+ MidFilter()
+ minFilter()
+ maxFilter()
+ PassFilter()
+ BlockFilter()
+ faceDetect()
+ HoughStraight()
+ HoughCurve()
+ videoDetect()
+
+
diff --git a/DigitalImageSystem By WXT(Tutu).rar b/DigitalImageSystem By WXT(Tutu).rar
new file mode 100644
index 0000000..87f6dd6
Binary files /dev/null and b/DigitalImageSystem By WXT(Tutu).rar differ