本文實例講述了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è)計有所幫助。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
