【OpenCV】显著区域检测

本文介绍在行人再识别项目中应用OpenCV进行显著性检测的方法。通过VS2015和OpenCV3.2环境,实现了从ARGB图像到显著性区域的转换。主要代码包括Saliency_h、Saliency_cpp和Main_cpp。文中还提到将32位无符号整数ARGB图像数据转换为程序所需格式,并讨论了转换后数据的一维表示。最后展示了原图像和显著性区域的检测结果。

写在前面

最近在做毕设,题目是行人再识别。目前只是用行人区域的颜色直方图进行匹配,效果比较不理想。老板推荐加入显著性检测,然后就搞了搞。

环境

  • VS2015
  • OpenCV3.2

代码

Saliency_h

// Saliency.h: interface for the Saliency class.
//
//////////////////////////////////////////////////////////////////////
//===========================================================================
//  Copyright (c) 2009 Radhakrishna Achanta [EPFL] 
//===========================================================================

#if !defined(_SALIENCY_H_INCLUDED_)
#define _SALIENCY_H_INCLUDED_

#include <vector>
#include <cfloat>
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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值