📜  Python Mahotas – 简介

📅  最后修改于: 2022-05-13 01:54:31.936000             🧑  作者: Mango

Python Mahotas – 简介

Mahotas是一个用于Python的计算机视觉和图像处理和操作库。库是函数和方法的集合,允许您执行许多操作而无需编写数百行代码。 Mahotas 包含许多与数组一起操作的算法,mahotas 目前拥有超过 100 种用于图像处理和计算机视觉的函数,并且还在不断增长。

Mahotas 提供了一个很好的解决方案来寻找图像中的模式,例如“Where's Wally Problem”可以使用 Mahotas 轻松解决。

如何安装 Mahotas:

pip install mahotas

Mahotas 中可用的著名算法:
1. 分水岭
2.凸点计算。
3. 碰碰运气,瘦身。
4. Zernike & Haralick、LBP 和 TAS 特征。
5. Speeded-Up Robust Features (SURF),一种局部特征。
6. 阈值化。
7. 卷积。
8. Sobel边缘检测。
9. 样条插值
10. SLIC 超像素。

示例 1:加载图像

Python3
# importing required libraries
import numpy as np
import mahotas
import pylab
 
# loading image
img = mahotas.imread('dog_image.png')
 
# showing the original image
imshow(img)
show()


Python3
# importing required libraries
import pylab as p
import numpy as np
import mahotas
 
# creating numpy array of type bool
f = np.ones((256, 256), bool)
 
# setting false values
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
 
# creating a distance using numpy array
dmap = mahotas.distance(f)
 
# showing image
p.imshow(dmap)
p.show()


输出 :

示例 2:创建距离变换

Python3

# importing required libraries
import pylab as p
import numpy as np
import mahotas
 
# creating numpy array of type bool
f = np.ones((256, 256), bool)
 
# setting false values
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
 
# creating a distance using numpy array
dmap = mahotas.distance(f)
 
# showing image
p.imshow(dmap)
p.show()

输出 :