http://blog.youkuaiyun.com/onezeros/archive/2011/04/03/6299745.aspx
国外的一个图像显著区域检测代码及其效果图 saliency region detection
效果图:
可以直接测试的代码:
头文件:
// Saliency.h: interface for the Saliency class.
//
//////////////////////////////////////////////////////////////////////
//===========================================================================
// Copyright (c) 2009 Radhakrishna Achanta [EPFL]
//===========================================================================
#if !defined(_SALIENCY_H_INCLUDED_)
#define _SALIENCY_H_INCLUDED_
#include
#include
using namespace std;
class Saliency
{
public:
Saliency();
virtual ~Saliency();
public:
void GetSaliencyMap(
const vector<unsigned int>& inputimg,//INPUT: ARGB buffer in row-major order
const int& width,
const int& height,
vector<double>& salmap,//OUTPUT: Floating point buffer in row-major order
const bool& normalizeflag = true);//false if normalization is not needed
private:
void RGB2LAB(
const vector<unsigned int>& ubuff,
vector<double>& lvec,
vector<double>& avec,
vector<double>& bvec);
void GaussianSmooth(
const vector<double>& inputImg,
const int& width,
const int& height,
const vector<double>& kernel,
vector<double>& smoothImg);
//==============================================================================
/// Normalize
//==============================================================================
void Normalize(
const vector<double>& input,
const int& width,
const int& height,
vector<double>& output,
const int& normrange = 255)
{
double maxval(0);
double minval(DBL_MAX);
{
int i(0);
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
if( maxval < input[i] ) maxval = input[i];
if( minval > input[i] ) minval = input[i];
i++;
}
}}
double range = maxval-minval;
if( 0 == range ) range = 1;
int i(0);
output.clear();
output.resize(width*height);
for( int y = 0; y < height; y++ )