ViSP  2.8.0
vpHistogram.h
1 /****************************************************************************
2  *
3  * $Id: vpHistogram.h 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Gray level histogram manipulation.
36  *
37  * Author:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
42 
43 
51 #ifndef vpHistogram_h
52 #define vpHistogram_h
53 
54 #include <visp/vpImage.h>
55 #include <visp/vpHistogramPeak.h>
56 #include <visp/vpHistogramValey.h>
57 
58 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
59 # include <visp/vpList.h>
60 #endif
61 
62 #include <list>
63 
115 class VISP_EXPORT vpHistogram
116 {
117 public:
118  vpHistogram();
119  vpHistogram(const vpHistogram &h);
121  virtual ~vpHistogram();
122 
123  vpHistogram & operator=(const vpHistogram &h);
124 
145  inline unsigned operator[](const unsigned char level) const
146  {
147  return histogram[level];
148 
149  };
170  inline unsigned operator()(const unsigned char level) const
171  {
172  return histogram[level];
173  };
194  inline unsigned get(const unsigned char level) const
195  {
196  return histogram[level];
197  };
198 
216  inline void set(const unsigned char level, unsigned int value)
217  {
218  histogram[level] = value;
219  };
220 
221  void calculate(const vpImage<unsigned char> &I);
222  void smooth(const unsigned int fsize = 3);
223  unsigned getPeaks(std::list<vpHistogramPeak> & peaks);
224  unsigned getPeaks(unsigned char dist,
225  vpHistogramPeak & peak1,
226  vpHistogramPeak & peak2);
227  bool getPeaks(unsigned char dist,
228  vpHistogramPeak & peakl,
229  vpHistogramPeak & peakr,
230  vpHistogramValey & valey);
231  unsigned getValey(std::list<vpHistogramValey> & valey);
232  bool getValey(const vpHistogramPeak & peak1,
233  const vpHistogramPeak & peak2,
234  vpHistogramValey & valey);
235  unsigned getValey(unsigned char dist,
236  const vpHistogramPeak & peak,
237  vpHistogramValey & valeyl,
238  vpHistogramValey & valeyr);
239  unsigned sort(std::list<vpHistogramPeak> & peaks);
240 
241  bool write(const std::string &filename);
242  bool write(const char *filename);
243 
252  inline unsigned getSize()
253  {
254  return size;
255  };
256 
278  inline unsigned * getValues()
279  {
280  return histogram;
281  };
282 
283 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
284 
287  vp_deprecated unsigned getPeaks(vpList<vpHistogramPeak> & peaks);
288  vp_deprecated unsigned getValey(vpList<vpHistogramValey> & valey);
289  vp_deprecated unsigned sort(vpList<vpHistogramPeak> & peaks);
290 #endif
291 
292 private:
293  void init(unsigned size = 256);
294 
295  unsigned int *histogram;
296  unsigned size; // Histogram size (max allowed 256)
297 };
298 
299 
300 
301 #endif
302 
303 /*
304  * Local variables:
305  * c-basic-offset: 2
306  * End:
307  */
unsigned getSize()
Definition: vpHistogram.h:252
Provide simple list management.
Definition: vpList.h:112
Class to compute a gray level image histogram.
Definition: vpHistogram.h:115
Declaration of the peak (maximum value) in a gray level image histogram.
unsigned operator[](const unsigned char level) const
Definition: vpHistogram.h:145
unsigned operator()(const unsigned char level) const
Definition: vpHistogram.h:170
Declaration of the valey (minimum value) in a gray level image histogram.
void set(const unsigned char level, unsigned int value)
Definition: vpHistogram.h:216
unsigned * getValues()
Definition: vpHistogram.h:278