Python圖像處理模塊ndimage用法實例分析
本文實例講述了Python圖像處理模塊ndimage用法。分享給大家供大家參考,具體如下:
一 原始圖像
1 代碼
from scipy import misc from scipy import ndimage import matplotlib.pyplot as plt face = misc.face()#face是測試圖像之一 plt.figure()#創(chuàng)建圖形 plt.imshow(face)#繪制測試圖像 plt.show()#原始圖像
2 運行結(jié)果

二 高斯濾波
1 代碼
from scipy import misc from scipy import ndimage import matplotlib.pyplot as plt face = misc.face()#face是測試圖像之一 plt.figure()#創(chuàng)建圖形 blurred_face = ndimage.gaussian_filter(face, sigma=7)#高斯濾波 plt.imshow(blurred_face) plt.show()
2 運行結(jié)果

三 邊緣銳化處理
1 代碼
from scipy import misc from scipy import ndimage import matplotlib.pyplot as plt face = misc.face()#face是測試圖像之一 plt.figure()#創(chuàng)建圖形 blurred_face1 = ndimage.gaussian_filter(face, sigma=1)#邊緣銳化 blurred_face3 = ndimage.gaussian_filter(face, sigma=3) sharp_face = blurred_face3 +6*(blurred_face3-blurred_face1) plt.imshow(sharp_face) plt.show()
2 運行結(jié)果

四 中值濾波
1 代碼
from scipy import misc from scipy import ndimage import matplotlib.pyplot as plt face = misc.face()#face是測試圖像之一 plt.figure()#創(chuàng)建圖形 median_face = ndimage.median_filter(face,7)#中值濾波 plt.imshow(median_face) plt.show()
2 運行結(jié)果

更多關(guān)于Python相關(guān)內(nèi)容可查看本站專題:《Python圖片操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進階經(jīng)典教程》
希望本文所述對大家Python程序設(shè)計有所幫助。
相關(guān)文章
Pandas統(tǒng)計計數(shù)value_counts()的使用
本文主要介紹了Pandas統(tǒng)計計數(shù)value_counts()的使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07
Python的Django框架實現(xiàn)數(shù)據(jù)庫查詢(不返回QuerySet的方法)
這篇文章主要介紹了Python的Django框架實現(xiàn)數(shù)據(jù)庫查詢(不返回QuerySet的方法)2020-05-05
Python OpenCV 使用滑動條來調(diào)整函數(shù)參數(shù)的方法
這篇文章主要介紹了Python OpenCV 使用滑動條來調(diào)整函數(shù)參數(shù)的方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
Python3.6筆記之將程序運行結(jié)果輸出到文件的方法

