資源簡介
壓縮包里是python的代碼文件(包含代碼),你的電腦安裝了python可直接打開,我放了一張圖片在里面,圖像處理包括了對圖形灰度化、腐蝕、圖片二值化、尋找最大輪廓、canny邊緣檢測、獲取hsv與rgb值、膨脹等技術。

代碼片段和文件信息
import?cv2?as?cv
import?tkinter?as?tk
import?numpy?as?np
from?datetime?import?datetime?as?time1
“““
Created?on?2019.12.10
@author:?wang
“““
def?save_picture(picture):
????news?=?time1.today()
????xx?=?time1.timetuple(news)??#得到時間元組
????text3?=?“%d-%d-%d----%d-%d-%d.png“?%?(xx[0]xx[1]xx[2]xx[3]xx[4]xx[5])
????cv.imwrite(text3picture)
????lists.insert(‘end‘“write?ok?:?%s?\n“%text3)
‘‘‘-----------------------------窗口------------------------------‘‘‘
window?=?tk.Tk()
window.title(‘last?homework‘)
window.geometry(‘800x508‘)
pic?=?cv.imread(‘picture.jpg‘)
HSV=cv.cvtColor(piccv.COLOR_BGR2HSV)
“““?------------------------------------放置狀態打印框--------------------------------------------?“““
list_scro?=?tk.Scrollbar(windowhighlightthickness?=?10)?????????#接受文本的滾動條
lists?=??tk.Text(window?bg?=?‘white‘width?=?32?heigh?=?16yscrollcommand=list_scro.set)???#顯示接收數據文本框
lists.place(x?=?300y?=?300)
list_scro.pack(side?=?tk.RIGHTfill?=?tk.Y)
list_scro.config(command?=?lists.yview)???#設置滾動條鏈接接收文本
‘‘‘---------------------------------標簽類---------------------------‘‘‘
‘‘‘---------------------------------二值化閾值---------------------------‘‘‘
ezhVar?=?tk.StringVar()
ezhVar.set(‘二值化閾值最小值‘)
ezhlabel?=?tk.Label(window?textvariable?=?ezhVar?bg?=?‘white‘?font?=?(‘Arial‘?12)width?=?16?heigh?=?1?)
ezhlabel.place(x=400?y?=?30)
ezhVar?=?tk.StringVar()
ezhVar.set(‘二值化閾值最大值‘)
ezhlabel?=?tk.Label(window?textvariable?=?ezhVar?bg?=?‘white‘?font?=?(‘Arial‘?12)width?=?16?heigh?=?1?)
ezhlabel.place(x=400?y?=?60)
ezhVar?=?tk.StringVar()
ezhVar.set(‘卷積核大小‘)
ezhlabel?=?tk.Label(window?textvariable?=?ezhVar?bg?=?‘white‘?font?=?(‘Arial‘?12)width?=?16?heigh?=?1?)
ezhlabel.place(x=400?y?=?90)
‘‘‘--------------------------------文本框類----------------------------------‘‘‘
ResolvingXText?=?tk.Entry(windowwidth?=?5)??#輸入分辨率?文本框
ResolvingXText.place(x=560?y?=?30)
ResolvingXText.insert(‘end‘‘127‘)???#給文本框設置默認值
ResolvingYText?=?tk.Entry(windowwidth?=?5)??#輸入分辨率?文本框
ResolvingYText.place(x=560?y?=?60)
ResolvingYText.insert(‘end‘‘255‘)???#給文本框設置默認值
ResolvingZText?=?tk.Entry(windowwidth?=?5)??#輸入分辨率?文本框
ResolvingZText.place(x=560?y?=?90)
ResolvingZText.insert(‘end‘‘10‘)???#給文本框設置默認值
‘‘‘-----------------------------------保存文件---------------------------‘‘‘
def?set_save()?:?????#設置最小邊長函數
????global?pic
????if?pic?is?not?None:
????????save_picture(pic)
closeButton?=?tk.Button(window?text?=?‘save‘?width?=?6?heigh?=?1?command?=?set_save)
closeButton.place(x=150y=20)
‘‘‘-----------------------------------打開文件---------------------------‘‘‘
def?set_open()?:?????#設置最小邊長函數
?????cv.imshow(‘nowpic‘pic)
?????cv.waitKey(1)
closeButton?=?tk.Button(window?text?=?‘open‘?width?=?6?heigh?=?1?command?=?set_open)
closeButton.place(x=90y=20)
‘‘‘-----------------------------------關閉---------------------------‘‘‘
def?close()?:?????#設置最小邊長函數
????cv.destroyAllWindows()
????quit()
closeButton?=?tk.Button(window
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????44432??2019-12-10?23:28??python圖像處理\picture.jpg
?????文件???????8289??2019-12-24?12:33??python圖像處理\ver0.1.py
?????目錄??????????0??2020-03-11?18:26??python圖像處理
-----------?---------??----------?-----??----
????????????????52721????????????????????3
- 上一篇:cplex教程python
- 下一篇:SVM實現文本分類代碼
評論
共有 條評論