mamba-image python 包的安装

1. mamba-image 简介

官方网站是: http://www.mamba-image.org/
Mamba is an open-source Mathematical Morphology library written in C and Python.
Its name actually stands for MA thematical M orphology li B r A ry
Mamba was created and is updated with the following philosophy:
a. Portable, with support of multiple platforms and architectures
b. Simple
c. Fast
d. Fit for educational purposes and for applications prototyping
e. Free (through free licensing, see the user manual)

注意: pip安装的mamba不是这个mamba-image!

2. exe安装

下载地址: https://github.com/nicolasBeucher/mamba-image/releases/tag/2.0.2
mamba-image python 包的安装_第1张图片
需要有python2.7 或者 3.4的环境才可以使用此方法.
由于没有最新的3.6版本. 下面自己编译安装.

3.Win10 64位 + VS2013 + python 3.6 编译 mamba-Image

源码下载: https://github.com/nicolasBeucher/mamba-image
使用cmake, 指定vs2013 64位. 设置python.exe的路径. 我这里用的Anaconda的python路径.
mamba-image python 包的安装_第2张图片
生成vs2013的sln就可以了.

打开sln文件, 菜单->生成->批量生成->AllBuild->Release->生成按钮.

mamba-image python 包的安装_第3张图片

生成的python文件夹下有一个setup.py文件.这个就是安装文件.
mamba-image python 包的安装_第4张图片
在此路径下, command运行:

python setup.py install

安装就完成了.
mamba-image python 包的安装_第5张图片

4. 运行example中Interactive_segment_usage例程:

推荐使用pycharm IDE.

# exampleE11.py
# IN snake.png
# OUT interseg_snap.png

## TITLE #######################################################################
# mambaDisplay.extra interactive segment usage

## DESCRIPTION #################################################################
# This is a small demonstration of the mambaDisplay.extra interactive
# segmentation GUI. It allows you to segment an image using the watershed
# algorithm (processing the gradient image) with user-defined markers. Its
# behavior is very similar to the magic selection you can find in image
# processing programs such as GIMP.

## SCRIPT ######################################################################
# Importing mamba and mambaDisplay.extra
from mamba import *
import mambaDisplay.extra

# Opening an image
im = imageMb('snake.png')
# The 32-bit image in which the segmentation result will be placed
imSeg = imageMb(im, 32)

# Calling the interactive segmentation GUI
#
# This will block script progression until you hit the close button.
# To create a marker simply click on the image. If you do that
# while pressing the control button on your keyboard, the marker
# will be a line between your previous click on the new one (creating a
# unique marker). The function return the list of markers.
#
# Of course the display can be zoom in or out and has most of the 
# functionalities available in the standard mamba display.
print(mambaDisplay.extra.interactiveSegment(im, imSeg))

可以交互式地做图像分割. 绿线是marker, 红线是分水岭算法得出的分水岭.
mamba-image python 包的安装_第6张图片

5. 注意几个问题:

  1. 直接将src/python的代码复制到安装路径是不能调用的, 缺dll等文件. 也不能不做cmake直接python setup.py install, 会报错, 缺少dll.
  2. swig.exe找不到. 下载swig windows版本. 解压放到某个目录下, 并将此路径添加到系统path中. 这一步需要重启系统.
  3. vcvarball.bat 找不到. 下载visualcppbuildtools_full.exe 安装. 不需要重启系统. 或者更直接的, 安装VS2015. windows 使用的python 3.6 是VS2015编译的. 所以安装一个VS2015可以避免很多环境问题.
  4. install后例程运行报错, 提示缺少imageMb等函数. imageMb在base.py中定义(source insight 可以查找工程内所有文件中的关键字). 安装过程缺少了base.py__init.py__文件. 将源码src/python/mamba/中的这两个文件复制到安装路径的mamba文件夹内即可(复制完成后见下图). 可以使用beyond compare查看还缺少哪些文件(我这里没有缺少其他文件了). 这一步不需要重启系统.
    mamba-image python 包的安装_第7张图片

你可能感兴趣的:(图像处理,Python,磨刀不误,mamba-image,python,vcvarball.bat,swig.exe,vs2013)