MahotasPython图像处理
Mahotas 是一个 Python 的图像处理库,包含大量的图像处理算法,使用 C++ 实现的算法,处理性能相当好。
示例代码:
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()
评论