automatic commit
[folded-ctf.git] / pi_feature.h
1 /*
2  *  folded-ctf is an implementation of the folded hierarchy of
3  *  classifiers for object detection, developed by Francois Fleuret
4  *  and Donald Geman.
5  *
6  *  Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of folded-ctf.
10  *
11  *  folded-ctf is free software: you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published
13  *  by the Free Software Foundation, either version 3 of the License,
14  *  or (at your option) any later version.
15  *
16  *  folded-ctf is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with folded-ctf.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25
26 /*
27
28   A PiFeatures is the central new idea of this approach. It is a
29   feature which can be evaluated on a pair image / referential, where
30   the referential is computed from a pose cell.
31
32 */
33
34 #ifndef PI_FEATURE_H
35 #define PI_FEATURE_H
36
37 #include "misc.h"
38 #include "global.h"
39 #include "rich_image.h"
40 #include "pi_referential.h"
41
42 class PiFeature {
43
44   enum {
45     PF_EDGE_THRESHOLDING,
46     PF_EDGE_HISTOGRAM_COMPARISON,
47     PF_GRAYSCALE_HISTOGRAM_COMPARISON,
48   } _type;
49
50   int _tag, _edge_scale;
51   Rectangle _window_a, _window_b;
52   int _registration_a, _registration_b;
53
54   int random_registration_mode(int level);
55   void randomize_window(int registration_mode, Rectangle *window);
56   void draw_window(RGBImage *image, int registration_mode, Rectangle *window);
57
58   // EDGE THRESHOLDING
59
60   scalar_t response_edge_thresholding(RichImage *image, PiReferential *referential);
61   void draw_edge_thresholding(RGBImage *image, int r, int g, int b,
62                               PiReferential *referential);
63   void print_edge_thresholding(ostream *os);
64
65   // EDGE ORIENTATION HISTOGRAM COMPARISON
66
67   scalar_t response_edge_histogram_comparison(RichImage *image, PiReferential *referential);
68   void draw_edge_histogram_comparison(RGBImage *image, int r, int g, int b,
69                                       PiReferential *referential);
70   void print_edge_histogram_comparison(ostream *os);
71
72   // GRAYSCALE HISTOGRAM COMPARISON
73
74   scalar_t response_grayscale_histogram_comparison(RichImage *image, PiReferential *referential);
75   void draw_grayscale_histogram_comparison(RGBImage *image,
76                                            int r, int g, int b,
77                                            PiReferential *referential);
78   void print_grayscale_histogram_comparison(ostream *os);
79
80 public:
81
82   void randomize(int level);
83
84   scalar_t response(RichImage *image, PiReferential *referential);
85
86   void draw(RGBImage *image,
87             int r, int g, int b,
88             PiReferential *referential);
89
90   void print(ostream *os);
91 };
92
93 #endif