X-Boost  2.3.8
SumAreaFeature.h
Go to the documentation of this file.
1 /* XBoost: Ada-Boost and Friends on Haar/ICF/HOG Features, Library and ToolBox
2  *
3  * Copyright (c) 2008-2014 Paolo Medici <medici@ce.unipr.it>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _SUM_AREA_FEATURE_H
22 #define _SUM_AREA_FEATURE_H
23 
28 #include <vector>
29 #include <iostream>
30 
35  int x0,y0,x1,y1;
36 public:
37 
39  typedef unsigned int InputDataType;
40 
42  typedef int DescriptorType;
43 public:
44 
45  SumAreaFeature() { }
46 
48  static std::string signature() { return "sum"; }
49 
50  inline int response(const unsigned int *pIntImage, int stride) const
51  {
52  return (int) pIntImage[x1 + y1 * stride] + (int) pIntImage[x0 + y0 * stride] - (int) pIntImage[x1 + y0 * stride] - (int) pIntImage[x0 + y1 * stride];
53  }
54 
55 
56  inline int operator() (const unsigned int *pIntImage, int stride) const
57  {
58  return response(pIntImage, stride);
59  }
60 
64  void rescale(int sx, int sy)
65  {
66  x0 = (x0 * sx + sx - 1);
67  y0 = (y0 * sy + sy - 1);
68  x1 = (x1 * sx + sx - 1);
69  y1 = (y1 * sy + sy - 1);
70  }
71 };
72 
73 
74  std::istream & operator >> (std::istream & in, SumAreaFeature & s);
75  std::ostream & operator << (std::ostream & out, const SumAreaFeature & s);
76 
78 
81  long A,B,C,D;
82 public:
83 
85 OptimizedSumAreaFeature(const SumAreaFeature &src, long offset, long stride)
86 {
87  A = offset + src.x0 + src.y0 * stride;
88  B = offset + src.x0 + src.y1 * stride;
89  C = offset + src.x1 + src.y0 * stride;
90  D = offset + src.x1 + src.y1 * stride;
91 
92 }
93 
95 inline int response(const unsigned int *pIntImage) const
96 {
97  return (int) pIntImage[A] + (int) pIntImage[D] - (int) pIntImage[B] - (int) pIntImage[C];
98 }
99 
100 };
101 
102 #endif
OptimizedSumAreaFeature(const SumAreaFeature &src, long offset, long stride)
Definition: SumAreaFeature.h:85
Sum of a rectangular area, implemented on top of Integral Image.
Definition: SumAreaFeature.h:32
static std::string signature()
Definition: SumAreaFeature.h:48
int response(const unsigned int *pIntImage) const
compute the response
Definition: SumAreaFeature.h:95
unsigned int InputDataType
type of data requested by this Feature Extractor
Definition: SumAreaFeature.h:39
void rescale(int sx, int sy)
Definition: SumAreaFeature.h:64
int DescriptorType
type of data returned by this feature extractor
Definition: SumAreaFeature.h:42
int x0
Definition: SumAreaFeature.h:35
an optimized SumAreaFeature
Definition: SumAreaFeature.h:80