|
degate 0.1.1
|
#include <BackgroundClassifier.h>

Public Member Functions | |
| BackgroundClassifier (std::tr1::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::tr1::shared_ptr < ImageType > | img |
| HistogramType | hist_bg |
| HistogramType | hist_fg |
| const unsigned int | width |
| const unsigned int | threshold |
| const std::string | cl_name |
Definition at line 59 of file BackgroundClassifier.h.
| degate::BackgroundClassifier< ImageType, HistogramType >::BackgroundClassifier | ( | std::tr1::shared_ptr< ImageType > | _img, |
| unsigned int | _width, | ||
| unsigned int | _threshold, | ||
| std::string const & | _name | ||
| ) | [inline] |
| 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.
| 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.
| std::string degate::BackgroundClassifier< ImageType, HistogramType >::get_name | ( | ) | const [inline, virtual] |
Implements Classifier< coord_type >.
Definition at line 83 of file BackgroundClassifier.h.
References degate::BackgroundClassifier< ImageType, HistogramType >::cl_name.
{
return cl_name;
}
| int degate::BackgroundClassifier< ImageType, HistogramType >::recognize | ( | coord_type & | v | ) | [inline, virtual] |
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;
}
const std::string degate::BackgroundClassifier< ImageType, HistogramType >::cl_name [private] |
Definition at line 67 of file BackgroundClassifier.h.
Referenced by degate::BackgroundClassifier< ImageType, HistogramType >::get_name().
HistogramType degate::BackgroundClassifier< ImageType, HistogramType >::hist_bg [private] |
Definition at line 64 of file BackgroundClassifier.h.
Referenced by degate::BackgroundClassifier< ImageType, HistogramType >::add_background_areas(), and degate::BackgroundClassifier< ImageType, HistogramType >::recognize().
HistogramType degate::BackgroundClassifier< ImageType, HistogramType >::hist_fg [private] |
Definition at line 64 of file BackgroundClassifier.h.
Referenced by degate::BackgroundClassifier< ImageType, HistogramType >::add_foreground_areas(), and degate::BackgroundClassifier< ImageType, HistogramType >::recognize().
const std::tr1::shared_ptr<ImageType> degate::BackgroundClassifier< ImageType, HistogramType >::img [private] |
Definition at line 63 of file BackgroundClassifier.h.
Referenced by degate::BackgroundClassifier< ImageType, HistogramType >::add_background_areas(), degate::BackgroundClassifier< ImageType, HistogramType >::add_foreground_areas(), and degate::BackgroundClassifier< ImageType, HistogramType >::recognize().
const unsigned int degate::BackgroundClassifier< ImageType, HistogramType >::threshold [private] |
Definition at line 66 of file BackgroundClassifier.h.
Referenced by degate::BackgroundClassifier< ImageType, HistogramType >::recognize().
const unsigned int degate::BackgroundClassifier< ImageType, HistogramType >::width [private] |
Definition at line 65 of file BackgroundClassifier.h.
Referenced by degate::BackgroundClassifier< ImageType, HistogramType >::recognize().
1.7.4