资源简介
2012年CVPR上备受关注的一篇快速的显著性检测文章:Saliency Filters: Contrast Based Filtering for Salient Region Detection的代码现在可以在第二作者 Philipp Krähenbühl 的个人主页上下载了。
修改了代码的一些错误,需要搭建好opencv平台,直接编译即可。
代码片段和文件信息
/*
Copyright (c) 2012 Philipp Krähenbühl
All rights reserved.
Redistribution and use in source and binary forms with or without
modification are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Stanford University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ‘‘AS IS‘‘ AND ANY
EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY
DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES
(INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include “saliency/saliency.h“
#include
#include
#include
#include
#include
// Uncomment of you want to plot a precision-recall curve
// #define PLOT
#ifdef PLOT
#include “gnuplot_i.hpp“
#endif
#ifdef USE_TBB
#include
#include
#endif
const std::string ground_truth_path = “data/gt/“;
const std::string dataset_path = “data/images/“;
// Is the pr curve normalize by the image size (larger images count as much as smaller ones)
const int N_BINS = 256; // Number of bins for the PR curve
const double F_BETA2 = 0.3; // Beta^2 for the f-measure
class Dataset{
std::vector< std::string > im_ gt_ name_;
public:
Dataset(){
DIR *dp = opendir( ground_truth_path.c_str() );
for( dirent *dirp = readdir(dp); dirp != NULL; dirp = readdir(dp) ) {
std::string name = dirp->d_name;
if ( name.length() > 3 && name.substr( name.size()-3 ) == “bmp“ ) {
std::string jpgname = name.substr( 0 name.size()-3 ) + “jpg“;
gt_.push_back( ground_truth_path + “/“ + name );
im_.push_back( dataset_path + “/“ + jpgname );
name_.push_back( name.substr( 0 name.size()-4 ) );
}
}
closedir(dp);
}
int size() const {
return gt_.size();
}
Mat_ gt( int i ) const {
Mat im = imread( gt_[i] 0 );
Mat_ r;
// Make the saliency mask binary as it should be!!
Mat(im > 127).convertTo( r CV_32F
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7404 2012-11-09 09:08 evaluate.cpp
目录 0 2013-08-06 21:25 filter\
文件 51 2012-11-09 09:08 filter\CMakeLists.txt
文件 2718 2012-11-09 09:08 filter\filter.cpp
文件 2395 2012-11-09 09:08 filter\filter.h
文件 1610 2012-11-09 09:08 filter\permutohedral.cpp
文件 23323 2013-08-06 22:45 filter\permutohedral.h
文件 59428 2012-11-09 09:08 gnuplot_i.hpp
目录 0 2013-08-06 21:25 saliency\
文件 89 2012-11-09 09:08 saliency\CMakeLists.txt
文件 4197 2012-11-09 09:08 saliency\fastmath.h
文件 9623 2013-08-08 22:00 saliency\saliency.cpp
文件 3483 2013-08-06 21:37 saliency\saliency.h
文件 2305 2012-11-09 09:08 saliency\sse_defs.h
目录 0 2013-08-06 21:25 superpixel\
文件 92 2012-11-09 09:08 superpixel\CMakeLists.txt
文件 9621 2013-08-06 21:59 superpixel\superpixel.cpp
文件 2897 2013-08-06 21:49 superpixel\superpixel.h
文件 2256 2013-08-07 19:15 test_saliency.cpp
文件 2230 2012-11-09 09:08 test_superpixel.cpp
- 上一篇:以太网无缘光网络中关于动态带宽分配算法的介绍
- 下一篇:分布式数据库PPT课件
评论
共有 条评论