/usr/include/visp/vpHistogram.h is in libvisp-dev 2.9.0-3+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | /****************************************************************************
*
* $Id: vpHistogram.h 4574 2014-01-09 08:48:51Z fspindle $
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact INRIA about acquiring a ViSP Professional
* Edition License.
*
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
*
* This software was developed at:
* INRIA Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
* http://www.irisa.fr/lagadic
*
* If you have questions regarding the use of this file, please contact
* INRIA at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* Description:
* Gray level histogram manipulation.
*
* Author:
* Fabien Spindler
*
*****************************************************************************/
/*!
\file vpHistogram.h
\brief Declaration of the vpHistogram class.
Class vpHistogram defines gray level image histograms
*/
#ifndef vpHistogram_h
#define vpHistogram_h
#include <visp/vpImage.h>
#include <visp/vpHistogramPeak.h>
#include <visp/vpHistogramValey.h>
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
# include <visp/vpList.h>
#endif
#include <list>
/*!
\class vpHistogram
\ingroup Histogram
\brief Class to compute a gray level image histogram.
Here are two examples showing how to use this class to determine the
threshold which can be used to segment two objects.
The code below:
\code
vpImage<unsigned char> I;
...
unsigned char dist = 60;
vpHistogramValey valey;
vpHistogram h(I);
h.smooth(); // Filter the histogram values
vpHistogramPeak peakl, peakr; // Two highest peaks in the histogram
// - peakl: Peak on the left
// - peakr: Peak on the right
h.getPeaks(dist, peakl, peakr, valey);
unsigned char threshold; // Position of the valey between the two peaks
threshold = valey.getLevel();
\endcode
has the same behaviour than this one:
\code
vpImage<unsigned char> I;
...
unsigned char dist = 60;
vpHistogram h(I);
h.smooth(); // Filter the histogram values
vpHistogramPeak peak1, peak2; // Two highest peaks in the histogram
// - peak1: Highest peak
// - peakr: Second highest peak
// Get the two highest peaks
h.getPeaks(dist, peak1, peak2);
// Get the valey between the two highest peaks
vpHistogramValey valey;
h.getValey(peak1, peak2, valey);
unsigned char threshold; // Position of the valey between the two peaks
threshold = valey.getLevel();
\endcode
*/
class VISP_EXPORT vpHistogram
{
public:
vpHistogram();
vpHistogram(const vpHistogram &h);
vpHistogram(const vpImage<unsigned char> &I);
virtual ~vpHistogram();
vpHistogram & operator=(const vpHistogram &h);
/*!
Return the number of pixels having the gray \e level.
\param level : Gray level in the histogram.
\return Number of pixels having the gray level.
\code
vpImage<unsigned char> I; // A gray level image
vpHistogram h;
h.calculate(I); // Histogram of the gray level image
// Print the histogram values
for (int i=0; i < h.getSize(); i ++)
printf("%d: %d\n", i, h[i]);
\endcode
*/
inline unsigned operator[](const unsigned char level) const
{
return histogram[level];
};
/*!
Return the number of pixels having the gray \e level.
\param level : Gray level in the histogram.
\return Number of pixels having the gray level.
\code
vpImage<unsigned char> I; // A gray level image
vpHistogram h;
h.calculate(I); // Histogram of the gray level image
// Print the histogram values
for (int i=0; i < h.getSize(); i ++)
printf("%d: %d\n", i, h(i));
\endcode
*/
inline unsigned operator()(const unsigned char level) const
{
return histogram[level];
};
/*!
Return the number of pixels having the gray \e level.
\param level : Gray level in the histogram.
\return Number of pixels having the gray level.
\code
vpImage<unsigned char> I; // A gray level image
vpHistogram h;
h.calculate(I); // Histogram of the gray level image
// Print the histogram values
for (int i=0; i < h.getSize(); i ++)
printf("%d: %d\n", i, h.get(i));
\endcode
*/
inline unsigned get(const unsigned char level) const
{
return histogram[level];
};
/*!
Set the number of pixels having the gray \e level.
\param level : Gray level in the histogram. Level is in [0:255]
\param value : Number of pixels having the gray level.
\code
vpHistogram h;
// Set histogram values
for (int i=0; i < h.getSize(); i ++)
h.set(i, i*2); // for each level i, set a value of 2*i
\endcode
*/
inline void set(const unsigned char level, unsigned int value)
{
histogram[level] = value;
};
void calculate(const vpImage<unsigned char> &I);
void smooth(const unsigned int fsize = 3);
unsigned getPeaks(std::list<vpHistogramPeak> & peaks);
unsigned getPeaks(unsigned char dist,
vpHistogramPeak & peak1,
vpHistogramPeak & peak2);
bool getPeaks(unsigned char dist,
vpHistogramPeak & peakl,
vpHistogramPeak & peakr,
vpHistogramValey & valey);
unsigned getValey(std::list<vpHistogramValey> & valey);
bool getValey(const vpHistogramPeak & peak1,
const vpHistogramPeak & peak2,
vpHistogramValey & valey);
unsigned getValey(unsigned char dist,
const vpHistogramPeak & peak,
vpHistogramValey & valeyl,
vpHistogramValey & valeyr);
unsigned sort(std::list<vpHistogramPeak> & peaks);
bool write(const std::string &filename);
bool write(const char *filename);
/*!
Get the histogram size.
\return The size of the histogram, or the image maximum gray
levels numbers.
\sa getValues()
*/
inline unsigned getSize()
{
return size;
};
/*!
Get the histogram values.
\return A pointer to the array of histogram values. The size of
this array is given by getSize().
\code
vpImage<unsigned char> I; // A gray level image
vpHistogram h;
h.calculate(I); // Histogram of the gray level image
// Print the histogram values
unsigned char *values = h.getValues();
for (int i=0; i < h.getSize(); i ++)
printf("%d: %d\n", i, values[i]);
\endcode
\sa getSize()
*/
inline unsigned * getValues()
{
return histogram;
};
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
/*!
@name Deprecated functions
*/
vp_deprecated unsigned getPeaks(vpList<vpHistogramPeak> & peaks);
vp_deprecated unsigned getValey(vpList<vpHistogramValey> & valey);
vp_deprecated unsigned sort(vpList<vpHistogramPeak> & peaks);
#endif
private:
void init(unsigned size = 256);
unsigned int *histogram;
unsigned size; // Histogram size (max allowed 256)
};
#endif
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
|