MahotasPython圖像處理
Mahotas 是一個 Python 的圖像處理庫,包含大量的圖像處理算法,使用 C++ 實現(xiàn)的算法,處理性能相當(dāng)好。
示例代碼:
import numpy as np
import mahotas
import pylab
img = mahotas.imread('test.jpeg')
T_otsu = mahotas.thresholding.otsu(img)
seeds,_ = mahotas.label(img > T_otsu)
labeled = mahotas.cwatershed(img.max() - img, seeds)
pylab.imshow(labeled)
計算距離變換:
import pylab as p import numpy as np import mahotas f = np.ones((256,256), bool) f[200:,240:] = False f[128:144,32:48] = False # f is basically True with the exception of two islands: one in the lower-right # corner, another, middle-left dmap = mahotas.distance(f) p.imshow(dmap) p.show()
評論
圖片
表情
