日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Python數(shù)學(xué)形態(tài)學(xué)實(shí)例分析

系統(tǒng) 1969 0

本文實(shí)例講述了Python數(shù)學(xué)形態(tài)學(xué)。分享給大家供大家參考,具體如下:

一 原始隨機(jī)圖像

1、代碼

            
import numpy as np
import matplotlib.pyplot as plt
square = np.zeros((32,32))#全0數(shù)組
square[10:20,10:20]=1#把其中一部分設(shè)置為1
x, y =(32*np.random.random((2,15))).astype(np.int)#隨機(jī)位置
square[x,y]=1#把隨機(jī)位置設(shè)置為1
plt.imshow(square)#原始隨機(jī)圖像
plt.show()


          

2、運(yùn)行結(jié)果

Python數(shù)學(xué)形態(tài)學(xué)實(shí)例分析_第1張圖片

二 開(kāi)運(yùn)算

1、代碼

            
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
square = np.zeros((32,32))#全0數(shù)組
square[10:20,10:20]=1#把其中一部分設(shè)置為1
x, y =(32*np.random.random((2,15))).astype(np.int)#隨機(jī)位置
square[x,y]=1#把隨機(jī)位置設(shè)置為1
open_square = ndimage.binary_opening(square)#開(kāi)運(yùn)算
plt.imshow(open_square)
plt.show()


          

2、運(yùn)行結(jié)果

Python數(shù)學(xué)形態(tài)學(xué)實(shí)例分析_第2張圖片

三 膨脹運(yùn)算

1、代碼

            
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
square = np.zeros((32,32))#全0數(shù)組
square[10:20,10:20]=1#把其中一部分設(shè)置為1
x, y =(32*np.random.random((2,15))).astype(np.int)#隨機(jī)位置
square[x,y]=1#把隨機(jī)位置設(shè)置為1
eroded_square = ndimage.binary_erosion(square)#膨脹運(yùn)算
plt.imshow(eroded_square)
plt.show()


          

2、運(yùn)行結(jié)果

Python數(shù)學(xué)形態(tài)學(xué)實(shí)例分析_第3張圖片

四 閉運(yùn)算

1、代碼

            
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
square = np.zeros((32,32))#全0數(shù)組
square[10:20,10:20]=1#把其中一部分設(shè)置為1
x, y =(32*np.random.random((2,15))).astype(np.int)#隨機(jī)位置
square[x,y]=1#把隨機(jī)位置設(shè)置為1
closed_square = ndimage.binary_closing(square)#閉運(yùn)算
plt.imshow(closed_square)
plt.show()


          

2、運(yùn)行結(jié)果

Python數(shù)學(xué)形態(tài)學(xué)實(shí)例分析_第4張圖片

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Python數(shù)學(xué)運(yùn)算技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門(mén)與進(jìn)階經(jīng)典教程》

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 垫江县| 吴川市| 横山县| 保德县| 明星| 奉新县| 中江县| 通江县| 衡山县| 武汉市| 梅河口市| 潞城市| 隆林| 昌宁县| 辽源市| 曲周县| 新蔡县| 内丘县| 阿鲁科尔沁旗| 呼和浩特市| 温泉县| 沾化县| 白朗县| 双江| 乐陵市| 米脂县| 裕民县| 府谷县| 都江堰市| 临漳县| 顺平县| 松原市| 保亭| 应城市| 北碚区| 商河县| 通州市| 崇礼县| 柘城县| 德安县| 香港|