Mahotas(Python 计算机视觉、图像处理库)安装

来源:互联网 发布:linux设置ip地址命令 编辑:程序博客网 时间:2024/05/01 20:30

Mahotas 是计算机视觉和图像处理 Python 库。它包含大量图像处理算法,C++实现形式,提高了性能。完全基于 numpy 的数组作为它的数据类型,有一个非常干净的Python 算法接口。

包含算法

  • 分水岭。
  • 凸点计算。
  • 击中/击不中,细化算法。
  • 泽尼克&Haralick,枸杞多糖,和TAS的功能。
  • 基于freeimage的numpy图像加载(需要安装freeimage库)。
  • 加速的鲁棒特征(SURF)等。
  • 阈值。
  • 卷积。
  • Sobel边缘检测。
  • 多边形绘制
  • 距离变换
  • 特征计算
  • 样条插值

安装问题

在使用 pip install mahotas 安装过程中遇到一个错误:

building 'mahotas._histogram' extensionerror: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).

这里写图片描述

按照提示是缺少,Visual C++ 10.0

而在我的电脑上,只安装了VS2012

查找资料后得到了解释

由于是C++实现,所有在 window 中使用 pip 安装时需要有 C++ 编译器。

根据官网的解释,支持的编译器版本有:

  • Microsoft Visual C++ 2008 (x64, x86, and SP1 for CPython 2.6 and 2.7)
  • Visual C++ 2010 (x64, x86, for CPython 3.3 and 3.4)
  • Visual C++ 2015 (x64 and x86 for CPython 3.5) redistributable packages.

解决方案

在binary packages of mahotas 可以找到对应的二进制版本

下载对应版本二进制文件 mahotas-1.4.0.cp*******.whl

在命令行执行如下命令

pip install mathotas-1.4.0.cp*******.whl

运行测试

开启 Python 输入如下命令

import pylab as pimport numpy as npimport mahotas as mhf = np.ones((256,256), bool)f[200:,240:] = Falsef[128:144,32:48] = False# f is basically True with the exception of two islands: one in the lower-right# corner, another, middle-leftdmap = mh.distance(f)p.imshow(dmap)p.show()

终端输出如下即为,安装成功

这里写图片描述

参考链接

Mahotas 官网

How to install mahotas

Installing from Wheels

0 0