初学归一化切割和图像分割

  • Post author:
  • Post category:其他





最近正在研读一篇文献


FROM RARENESS TO COMPACTNESS: CONTRAST-AWARE IMAGE SALIENCY DETECTION


,学习基于对比度感知的显著性检测。








点击打开链接

中,作者大概分析了这篇文章的内容,本人不才尝试用matlab去实现文章讲述的方法。



在实现bin contrast时,顺便学习基于归一化切割(Normalized Cut)的图像分割,主要的参考文献是Normalized Cuts and Image Segmentation(J.Shi and J.Malik,TPAMI,2000),在百度还有中文翻译

(http://wenku.baidu.com/link?url=vZc7NyQS4b9ECZiaTS4UnPPVaMXcD1BMfq-LQb1l46ukjT92GsMo8oD1_00qVUAcAYaGkRgqhr5adh-9dEqMHBR6rWwBnsQ8TrDfKQWOnvy)




查到类似的matlab算法


MATLAB Normalized Cuts Segmentation Code



http://www.cis.upenn.edu/~jshi/software/





在Matlab R2011b运行NcutImage.m,第一次学习到matlab原来还能调用C++程序,将cpp文件在matlab command窗口编译成mex文件即可。


不过在编译中出现一些错误,在NcutImage.m所在的readme.txt说可以忽略一些 C++ non-mex file错误,但出现的错误肯定不能忽略(如下)



mex -largeArrayDims cimgnbmap.cpp

Error cimgnbmap.cpp: 172  illegal statement termination

Error cimgnbmap.cpp: 172  skipping `unsigned’ `int’

Error cimgnbmap.cpp: 172  undeclared identifier `qi’

Error cimgnbmap.cpp: 172  type error: pointer expected

Error cimgnbmap.cpp: 172  operands of = have illegal types `int’ and `pointer to unsigned int’

Error cimgnbmap.cpp: 173  illegal statement termination

Error cimgnbmap.cpp: 173  skipping `unsigned’ `int’

Error cimgnbmap.cpp: 173  undeclared identifier `qj’

Error cimgnbmap.cpp: 173  type error: pointer expected

Error cimgnbmap.cpp: 173  operands of = have illegal types `int’ and `pointer to unsigned int’

Error cimgnbmap.cpp: 180  type error: pointer expected

Error cimgnbmap.cpp: 183  type error: pointer expected

Error cimgnbmap.cpp: 188  type error: pointer expected

Warning cimgnbmap.cpp: 173   possible usage of qj before definition

Warning cimgnbmap.cpp: 172   possible usage of qi before definition

13 errors, 2 warnings

C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Compile of ‘cimgnbmap.cpp’ failed.





一直在cimgnbmap.cpp寻找问题,最后把qi,qj指针变量先在程序开头声明,然后在程序中间赋值,修改为

unsigned int *qi,*qj;
...
qi = (unsigned int *)mxGetData(out[0]);
qj = (unsigned int *)mxGetData(out[1]);
...


终于编译成功(mex -largeArrayDims cimgnbmap.cpp)


后面在Matlab R2011b编译不成功的cpp文件都可以这么修改,在程序开头声明变量,然后在程序中间赋值。



















版权声明:本文为zhanhong39原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。