degate  0.1.2
Public Member Functions | Private Attributes
degate::BackgroundClassifier< ImageType, HistogramType > Class Template Reference

#include <BackgroundClassifier.h>

Inheritance diagram for degate::BackgroundClassifier< ImageType, HistogramType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 BackgroundClassifier (std::shared_ptr< ImageType > _img, unsigned int _width, unsigned int _threshold, std::string const &_name)
std::string get_name () const
void add_background_areas (std::list< BoundingBox > const &bg_areas)
void add_foreground_areas (std::list< BoundingBox > const &fg_areas)
int recognize (coord_type &v)

Private Attributes

const std::shared_ptr< ImageType > img
HistogramType hist_bg
HistogramType hist_fg
const unsigned int width
const unsigned int threshold
const std::string cl_name

Detailed Description

template<class ImageType, typename HistogramType>
class degate::BackgroundClassifier< ImageType, HistogramType >

Definition at line 59 of file BackgroundClassifier.h.


Constructor & Destructor Documentation

template<class ImageType , typename HistogramType >
degate::BackgroundClassifier< ImageType, HistogramType >::BackgroundClassifier ( std::shared_ptr< ImageType >  _img,
unsigned int  _width,
unsigned int  _threshold,
std::string const &  _name 
) [inline]

Definition at line 72 of file BackgroundClassifier.h.

                                                 :
      img(_img),
      width(_width),
      threshold(_threshold),
      cl_name(_name) {
    }

Member Function Documentation

template<class ImageType , typename HistogramType >
void degate::BackgroundClassifier< ImageType, HistogramType >::add_background_areas ( std::list< BoundingBox > const &  bg_areas) [inline, virtual]

Implements degate::BackgroundClassifierBase.

Definition at line 88 of file BackgroundClassifier.h.

References degate::BackgroundClassifier< ImageType, HistogramType >::hist_bg, and degate::BackgroundClassifier< ImageType, HistogramType >::img.

                                                                    {

      for(std::list<BoundingBox>::const_iterator iter = bg_areas.begin();
          iter != bg_areas.end(); ++iter) {
        hist_bg.add_area(img, *iter);
      }
    }
template<class ImageType , typename HistogramType >
void degate::BackgroundClassifier< ImageType, HistogramType >::add_foreground_areas ( std::list< BoundingBox > const &  fg_areas) [inline, virtual]

Implements degate::BackgroundClassifierBase.

Definition at line 97 of file BackgroundClassifier.h.

References degate::BackgroundClassifier< ImageType, HistogramType >::hist_fg, and degate::BackgroundClassifier< ImageType, HistogramType >::img.

                                                                    {


      for(std::list<BoundingBox>::const_iterator iter = fg_areas.begin();
          iter != fg_areas.end(); ++iter) {
        hist_fg.add_area(img, *iter);
      }
    }
template<class ImageType , typename HistogramType >
std::string degate::BackgroundClassifier< ImageType, HistogramType >::get_name ( ) const [inline, virtual]
template<class ImageType , typename HistogramType >
int degate::BackgroundClassifier< ImageType, HistogramType >::recognize ( coord_type v) [inline, virtual]
Todo:
Cache data

Implements degate::BackgroundClassifierBase.

Definition at line 110 of file BackgroundClassifier.h.

References degate::BackgroundClassifier< ImageType, HistogramType >::hist_bg, degate::BackgroundClassifier< ImageType, HistogramType >::hist_fg, degate::BackgroundClassifier< ImageType, HistogramType >::img, degate::BackgroundClassifier< ImageType, HistogramType >::threshold, and degate::BackgroundClassifier< ImageType, HistogramType >::width.

                                  {
      unsigned int sum = 0;

      int radius = width >> 1;
      int x = v.first, y = v.second;

      if((x > radius && x < (int)img->get_width() - radius) &&
         (y > radius && y < (int)img->get_height() - radius)) {

        for(int _y = -radius; _y < radius; _y++)
          for(int _x = -radius; _x < radius; _x++) {
            rgba_pixel_t p = img->get_pixel(x + _x, y + _y);
            if(hist_fg.get_for_rgb(p) > hist_bg.get_for_rgb(p)) sum++;
          }
      }


      if(sum >= threshold) return 1;
      else return -1;
    }

Member Data Documentation

template<class ImageType , typename HistogramType >
const std::string degate::BackgroundClassifier< ImageType, HistogramType >::cl_name [private]
template<class ImageType , typename HistogramType >
HistogramType degate::BackgroundClassifier< ImageType, HistogramType >::hist_bg [private]
template<class ImageType , typename HistogramType >
HistogramType degate::BackgroundClassifier< ImageType, HistogramType >::hist_fg [private]
template<class ImageType , typename HistogramType >
const std::shared_ptr<ImageType> degate::BackgroundClassifier< ImageType, HistogramType >::img [private]
template<class ImageType , typename HistogramType >
const unsigned int degate::BackgroundClassifier< ImageType, HistogramType >::threshold [private]
template<class ImageType , typename HistogramType >
const unsigned int degate::BackgroundClassifier< ImageType, HistogramType >::width [private]

The documentation for this class was generated from the following file: