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)文章
Python基礎(chǔ)之教你怎么在M1系統(tǒng)上使用pandas
這篇文章主要介紹了Python基礎(chǔ)之教你怎么在M1系統(tǒng)上使用pandas,文中有非常詳細的代碼示例,對正在學習python基礎(chǔ)的小伙伴們有很好地幫助,需要的朋友可以參考下2021-05-05
pandas.DataFrame的pivot()和unstack()實現(xiàn)行轉(zhuǎn)列
這篇文章主要介紹了pandas.DataFrame的pivot()和unstack()實現(xiàn)行轉(zhuǎn)列,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-07-07
常用python數(shù)據(jù)類型轉(zhuǎn)換函數(shù)總結(jié)
這篇文章主要介紹了常用的python數(shù)據(jù)類型轉(zhuǎn)換函數(shù),并用實際例子說明了這些函數(shù)的用法,需要的朋友可以參考下2014-03-03
Python編程利用科赫曲線實現(xiàn)三維飄雪效果示例過程
這篇文章主要介紹了Python編程實現(xiàn)三維飄雪效果示例過程,通過本示例你可以自己做出一個浪漫的雪花飄落效果,有需要的朋友可以借鑒參考下2021-10-10

