Skip to main content

Mahotas:计算机视觉库

项目描述

马霍塔斯

Python 计算机视觉库

Mahotas 是一个在 numpy 数组上运行的快速计算机视觉算法库(全部用 C++ 实现以提高速度)。

特拉维斯 覆盖状态 下载 执照 使用 Anaconda 安装 在 https://gitter.im/luispedro/mahotas 加入聊天 福萨状态

支持 Python 版本 2.7、3.4+。

值得注意的算法:

Mahotas 目前拥有超过 100 种用于图像处理和计算机视觉的功能,并且还在不断增长。

发布计划大约是每月发布一个版本,每个版本都会带来新功能和改进的性能。不过,该接口非常稳定,并且使用多年前的 mahotas 版本编写的代码在当前版本中可以正常工作,只是它会更快(某些接口已弃用,几年后将被删除,但在同时,您只会收到警告)。在一些不幸的情况下,旧代码中存在错误,您的结果会变得更好。

如果您在出版物中使用它,请引用mahotas 论文(请参阅下面的引文中的详细信息)。

例子

这是一个使用高于阈值区域作为种子调用分水岭的简单示例(使用 mahotas 附带的示例文件)(我们使用 Otsu 定义阈值)。

# import using ``mh`` abbreviation which is common:
import mahotas as mh

# Load one of the demo images
im = mh.demos.load('nuclear')

# Automatically compute a threshold
T_otsu = mh.thresholding.otsu(im)

# Label the thresholded image (thresholding is done with numpy operations
seeds,nr_regions = mh.label(im > T_otsu)

# Call seeded watershed to expand the threshold
labeled = mh.cwatershed(im.max() - im, seeds)

这是一个非常简单的使用示例mahotas.distance(计算距离图):

import pylab as p
import numpy as np
import mahotas as mh

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 = mh.distance(f)
p.imshow(dmap)
p.show()

(这是在mahotas/demos/distance.py下。)

如何调用阈值函数:

import mahotas as mh
import numpy as np
from pylab import imshow, gray, show, subplot
from os import path

# Load photo of mahotas' author in greyscale
photo = mh.demos.load('luispedro', as_grey=True)

# Convert to integer values (using numpy operations)
photo = photo.astype(np.uint8)

# Compute Otsu threshold
T_otsu = mh.otsu(photo)
thresholded_otsu = (photo > T_otsu)

# Compute Riddler-Calvard threshold
T_rc = mh.rc(photo)
thresholded_rc = (photo > T_rc)

# Now call pylab functions to display the image
gray()
subplot(2,1,1)
imshow(thresholded_otsu)
subplot(2,1,2)
imshow(thresholded_rc)
show()

如您所见,我们依赖 numpy/matplotlib 进行许多操作。

安装

如果您使用的是conda ,则可以使用以下命令从 conda - forge 安装 mahotas :

conda config --add channels conda-forge
conda install mahotas

从源代码编译

您将需要 python(自然)、numpy 和 C++ 编译器。然后你应该能够使用:

pip install mahotas

您可以通过运行来测试您的安装:

python -c "import mahotas as mh; mh.test()"

如果您遇到问题,该手册有更多关于 mahotas 安装的文档,包括如何为多个平台查找预构建的。

引文

如果您在已发表的出版物上使用 mahotas,请引用:

Luis Pedro Coelho Mahotas:用于可编写脚本的计算机视觉的开源软件,《开放研究软件杂志》,第 1 卷,2013 年。 [ DOI ]

在中文提供格式:

@article{mahotas, author = {Luis Pedro Coelho}, title = {Mahotas: Open source software for scriptable computer vision}, journal = {Journal of Open Research Software}, year = {2013}, doi = { http:// dx.doi.org/10.5334/jors.ac},月 = {7 月},成交量 = {1} }

您可以使用该mahotas.citation()功能访问此信息。

发展

开发在 github ( http://github.com/luispedro/mahotas ) 上进行。

您可以DEBUG在编译之前设置环境变量以获得调试版本:

export DEBUG=1
python setup.py test

您可以将其设置为该值2以获得额外的检查:

export DEBUG=2
python setup.py test

请注意不要在生产中使用它,除非您正在寻找错误。调试级别 2 非常慢,因为它添加了许多运行时检查。

mahotas 源附带的Makefile也很有用。make debug将创建一个调试版本。make fast将创建一个非调试版本(您需要make clean介于两者之间)。make test将运行测试套件。

链接和联系人

文档https ://mahotas.readthedocs.io/

问题跟踪器github mahotas 问题

邮件列表:使用pythonvision 邮件列表提出问题、提交错误等。或者在stackoverflow 上提问(标记 mahotas)

主要作者和维护者Luis Pedro Coelho (关注twittergithub)。

Mahotas 还包括 Zachary Pincus [来自 scikits.image]、Peter J. Verveer [来自 scipy.ndimage] 和 Davis King [来自 dlib]、Christoph Gohlke 以及 其他人的代码。

关于用于生物图像信息学的 mahotas 的介绍

对于 Python 中计算机视觉的更一般性讨论, pythonvision 邮件列表是一个更好的场所,它会在未来为其他人生成一个公共讨论日志。您可以将它用于 Python 问题中的 mahotas 或一般计算机视觉。

近期变动

版本 1.4.9(2019 年 11 月 12 日)

  • 修复 FreeImage 检测(问题 #108)

版本 1.4.8(2019 年 10 月 11 日)

  • 修复共现矩阵计算(@databaaz 提供的补丁)

版本 1.4.7(2019 年 7 月 10 日)

  • 修复 Windows 上的编译

版本 1.4.6(2019 年 7 月 10 日)

  • 使 >2³¹ 体素的分水岭工作(问题 #102)
  • 从演示中删除牛奶
  • cwatershed()通过避免在、 majority_filter()和 颜色转换中不必要的数组复制来提高性能
  • 修复插值中的错误

1.4.5 版(2018 年 10 月 20 日)

  • 将代码升级到更新的 NumPy API(问题 #95)

版本 1.4.4(2017 年 11 月 5 日)

  • 修复 Bernsen 阈值处理中的错误(问题 #84)

版本 1.4.3(2016 年 10 月 3 日)

  • 修复分发(添加丢失的README.md文件)

版本 1.4.2(2016 年 10 月 2 日)

  • 修复resize\_to准确返回请求的大小
  • 修复在负值数组上计算纹理时的硬崩溃(问题 #72)
  • distance为 haralick 功能添加了参数(拉取请求 #76,由 Guillaume Lemaitre 撰写)

版本 1.4.1(2015 年 12 月 20 日)

  • 添加filter\_labeled功能
  • 修复 32 位平台和旧版本 numpy 上的测试

1.4.0 版(2015 年 7 月 8 日)

  • 添加mahotas-features.py脚本
  • 向 citation() 函数添加短参数
  • 将 max_iter 参数添加到 thin() 函数
  • 修复了没有背景时的 label.bbox(问题 #61,由 Daniel Haehn 报告)
  • bbox 现在允许尺寸大于 2(包括使用 as_sliceandborder参数时)
  • 尺寸大于 2 的扩展裁剪框
  • 向 haralick 功能添加了 use_x_minus_y_variance 选项
  • 添加功能lbp_names

1.3.0 版(2015 年 4 月 28 日)

  • 改进 freeimage.write_multipage 中的内存处理
  • 修复矩参数交换
  • 添加labeled.bbox函数
  • 将 return_mean 和 return_mean_ptp 参数添加到 haralick 函数
  • 添加高斯滤波器的差分(由王建宇)
  • 添加拉普拉斯滤波器(王建宇)
  • 修复传递不匹配参数时中值过滤器崩溃的问题
  • 修复 ndim > 2 的 gaussian_filter1d

版本 1.2.4(2014 年 12 月 23 日)

  • 添加基于 PIL 的 IO

版本 1.2.3(2014 年 11 月 8 日)

  • 在顶层导出 mean_filter
  • 修复 Zernike 矩计算(由 Sergey Demurin 报告)
  • 在没有 npy_float128 的平台上修复编译(Gabi Davar 的补丁)

版本 1.2.2(2014 年 10 月 19 日)

  • 将 minlength 参数添加到labeled_sum
  • 泛化 regmax/regmin 以处理浮点图像
  • 允许浮点输入cwatershed()
  • 正确检查 float16 和 float128 输入
  • 将 sobel 变成纯函数(即不对其输入进行归一化)
  • 修复sobel过滤

1.2.1 版(2014 年 7 月 21 日)

  • 在 setup.py 中显式设置 numpy.include_dirs() [Andrew Stromnov 的补丁]

1.2 版(2014 年 7 月 17 日)

  • 在 mahotas 命名空间级别导出 locmax|locmin
  • 将 ellipse_axes 从偏心代码中分离出来,因为它本身就很有用
  • 添加find()功能
  • 添加mean_filter()功能
  • 修复cwatershed()溢出的可能性
  • 使标签函数在接受更多类型时更加灵活
  • 修复 nD 图像崩溃close_holes()(对于 n > 2)
  • 删除 matplotlibwrap
  • 使用标准 setuptools 进行构建(而不是 numpy.distutils)
  • 添加overlay()功能

1.1.1 版(2014 年 7 月 4 日)

  • 使用 nD 图像修复 close_holes() 崩溃(对于 n > 2)

1.1.0(2014 年 2 月 12 日)

  • 更好的错误检查
  • 使用 1 阶修复整数图像的插值
  • 添加 resize_to & resize_rgb_to
  • 添加工作服覆盖范围
  • 修复 SLIC 超像素连接
  • 添加 remove_regions_where 函数
  • 修复卷积中的硬崩溃
  • 修复 convolve1d 中的轴处理
  • 为矩计算添加归一化

请参阅 旧版本的变更日志。

执照

福萨状态

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

内置发行版

mahotas_nh-1.4.10-cp38-cp38-win_amd64.whl (1.7 MB 查看哈希

已上传 cp38

mahotas_nh-1.4.10-cp38-cp38-win32.whl (1.7 MB 查看哈希

已上传 cp38

mahotas_nh-1.4.10-cp38-cp38-manylinux2010_x86_64.whl (5.5 MB 查看哈希

已上传 cp38

mahotas_nh-1.4.10-cp38-cp38-macosx_10_14_x86_64.whl (1.8 MB 查看哈希

已上传 cp38

mahotas_nh-1.4.10-cp37-cp37m-win_amd64.whl (1.7 MB 查看哈希

已上传 cp37

mahotas_nh-1.4.10-cp37-cp37m-win32.whl (1.7 MB 查看哈希

已上传 cp37

mahotas_nh-1.4.10-cp37-cp37m-manylinux2010_x86_64.whl (5.7 MB 查看哈希

已上传 cp37

mahotas_nh-1.4.10-cp37-cp37m-macosx_10_14_x86_64.whl (1.8 MB 查看哈希

已上传 cp37

mahotas_nh-1.4.10-cp36-cp36m-win_amd64.whl (1.7 MB 查看哈希

已上传 cp36

mahotas_nh-1.4.10-cp36-cp36m-win32.whl (1.7 MB 查看哈希

已上传 cp36

mahotas_nh-1.4.10-cp36-cp36m-manylinux2010_x86_64.whl (5.7 MB 查看哈希

已上传 cp36

mahotas_nh-1.4.10-cp36-cp36m-macosx_10_14_x86_64.whl (1.8 MB 查看哈希

已上传 cp36