Multivac 的学习与改造

最近研究了图像分割,个人认为图像分割是图像识别的基础,所以从图像分割开始。

图像分割技术非常多,这里不再列举,只是我的思路有2点:1、分割需要从总体开始,从上到下,从粗到细;2、需要结合先验知识例如先验形状来加快分割速度和准确度,因为我认为世界上我们可以看到的物体总是有限,总可以在有限范围中进行快速搜素匹配,这是我的出发点。

好,扯远了。

图像分割我搜了一个源代码,认为Multivac 是比较全面,并且是C++写,先从这个开始吧。

摘录说明如下

Multivac is a C++ object-oriented library that provides Front Tracking Algorithms. Multivac implements the Level Set Method and the Fast Marching Method and it can be used in a large variety of problems dealing with numerical simulation of interface propagation in 2D. This library has been successfully used to simulate a firespread model, for example.

This guide should allow new users to run Multivac for their own applications, even if they are not familiar with level set methods. It is advocated that a new user first: (1) reads this guide, (2) tries to run examples provided with Multivac and (3) displays the results thanks to the scripts (MultivacDisplay) available on Multivac homepage (http://spacetown.free.fr/fronts/).

This manual will not explain in detail the different algorithms nor the programming techniques used to create Multivac. More information about the different methods (the underlying theory) used by Multivac can be found in the book by J. A. Sethian: Level Set Methods and Fast Marching Methods, Cambridge University Press. Some further explanations, as well as other books on these two techniques, can be found on Stanley Osher's web site: http://www.math.ucla.edu/~sjo/ and on J. A. Sethian's web site:http://math.berkeley.edu/~sethian/level_set.html.



一:编译源代码

自己熟悉VS2010,下载后编译出现很多问题,看看主要是原来作者是在linux下编译的。重新修改了一下Include,细节不讲了,经过一番折腾,主要对template不是很熟,终于在vs2010编译没有错误了。

完成第一步了。


代码下载

http://download.csdn.net/detail/light169/8043701


近期重新编译原来的程序,居然又有了错误,原来没有问题,奇怪了。

Debug\baseclass.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>Debug\baseclass.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>Debug\baseclass.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>Debug\orthogonal.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>Debug\Errors.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>Debug\baseclass.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>Debug\baseclass.obj : warning LNK4042: 对象被多次指定;已忽略多余的指定
1>M.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Seldon::NoMemory::NoMemory(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0NoMemory@Seldon@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z),该符号在函数 __catch$??0?$Vector@NVVect_Full@Seldon@@V?$MallocAlloc@N@2@@Seldon@@QAE@H@Z$0 中被引用
1>M.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Seldon::IOError::IOError(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0IOError@Seldon@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z),该符号在函数 "public: void __thiscall Seldon::Vector<double,class Seldon::Vect_Full,class Seldon::MallocAlloc<double> >::WriteText(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?WriteText@?$Vector@NVVect_Full@Seldon@@V?$MallocAlloc@N@2@@Seldon@@QBEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用
1>M.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall Seldon::Error::~Error(void)" (??1Error@Seldon@@UAE@XZ),该符号在函数 "public: virtual __thiscall Seldon::NoMemory::~NoMemory(void)" (??1NoMemory@Seldon@@UAE@XZ) 中被引用
1>M.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall Seldon::NoMemory::What(void)" (?What@NoMemory@Seldon@@UAEXXZ)
1>M.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall Seldon::Error::What(void)" (?What@Error@Seldon@@UAEXXZ)
1>M.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall Seldon::IOError::What(void)" (?What@IOError@Seldon@@UAEXXZ)
1>E:\Document\ImageCenter\Multivac\VC2010\Multivac\Debug\Multivac.exe : fatal error LNK1120: 6 个无法解析的外部命令


最后检查,将Errors.hxx中


namespace Seldon
{
using namespace std;

....

}

修改为

using namespace std;

namespace Seldon
{

....

}

就可以了

直接运行,生成结果在result目录下。





二:试运行

使用例子track.cpp运行没有问题。但是怎么显示结果呢?

需要 MultivacDisplay ,MultivacDisplay是需要Python 的抓狂

只有看看Python 了

经过2周,研究了Python、PyQt、PyDev、Pillow等,差点找计算机装Linux,好在所有这些可以在Windows运行,改编初步结果出来了。

(PyDev for Eclipse,凑合可以用,别的编译环境没有研究)





代码已经上传(很简陋,见笑)

http://download.csdn.net/detail/light169/8095693

图片还无法显示,歇歇需要继续看Pillow ,颈椎病有点严重。


PyQt 最新成果





需要编译 extract_configuration.cpp

下载 cygwin  在其中安装g++

然后编译



g++ 编译之后,发现文件无法在windows下运行。

只好在vs2010下编译,也是有一些问题。主要修改:

1、main中增加宽字符转换

2、将string.cxx中的内容合并到string.hxx中,并包括

#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

然后编译通过,可是执行发现找不到section,跟踪检查,发现读取cfg文件时候有一个回车符,所以找不到。修改之后可以了


源程序下载地址



2014.11.13 终于可以显示结果了(所有参数都是缺省值,,其他程序修改划线宽度为0.1,front的值增加了50倍)。



本次源代码下载


下一步工作是具体分割算法


Linux and Python

http://www.cnblogs.com/vamei/

https://www.python.org/

http://ubuntu-china.cn

http://www.riverbankcomputing.com/software/pyqt/intro

http://numfocus.org/projects/index.html


Python 2.3 or higher – http://www.python.org/;
• NumPy – http://numpy.scipy.org/;
• Matplotlib – http://matplotlib.sourceforge.net/.
For image segmentation, it is necessary to load image from Python with:
• the Python Imaging Library – http://www.pythonware.com/products/pil/.
The GUI requires in addition:
• PyQt – http://www.riverbankcomputing.co.uk/pyqt/index.php.
In order to work in an interactive Python shell (like in Matlab or Mathematica), it is recommended to install IPython – http://ipython.scipy.org/. Instructions may be found on
Matplotlib website in section “Interactive”.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值