Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HistogramEqualization.hh
1 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
2 
3  Copyright (C) 2003, 2004 (see file CONTACTS for details)
4  Multimediale Systeme der Informationsverarbeitung
5  Institut fuer Informatik
6  Christian-Albrechts-Universitaet Kiel
7 
8  BIAS is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation; either version 2.1 of the License, or
11  (at your option) any later version.
12 
13  BIAS is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with BIAS; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21 
22 #ifndef __HistogramEqualization_hh__
23 #define __HistogramEqualization_hh__
24 
25 #include <Base/Image/Image.hh>
26 #include <Filter/FilterBase.hh>
27 
28 namespace BIAS {
29 /**
30  @brief perfoms a histogram equalization on a grey value image
31 
32  this improves the contrast of low contrast images by
33  redistributing the intensities on the histrogram.
34  this is done by reassigning the pixel intensities.
35 
36  the histogram equalization is done by the following steps:
37 
38  1. compute histogram (a bin for every possible grey value)
39  2. loop through filled bins b[n]. start with bin of lowest grey value. b[0]
40  for every bin b[i] compute sum s(i) of bin values so far ( b[0]+b[1]+ ... + b[i] )
41  3. create a look up table which maps the old intensity (grey) values to new ones.
42 
43  newgreyvalue(i) = (s(i)/NumOfAllPixelsInImage) * PossibleNumberOfGreyValues
44  4. use lookup table to remap input image
45 
46 
47  this template can be used for 8 or 16bit integer values.
48  don't try this with float or double.
49  */
50  template <class InputStorageType, class OutputStorageType>
51  class BIASImage_EXPORT HistogramEqualization:
52  public BIAS::FilterBase<InputStorageType, OutputStorageType> {
53 
54  public:
56  minCutOff_ = std::numeric_limits<InputStorageType>::min();
57  maxCutOff_ = std::numeric_limits<InputStorageType>::max();
58  }
59 
61 
62  virtual int Filter(const Image<InputStorageType>& src,
64 
65  int AdaptiveHistogramEqualization(const Image<InputStorageType>& src,Image<OutputStorageType>& dst,
66  unsigned int numRows=8, unsigned int numCols=8);
67 
68  void SetCutOffs(InputStorageType minCutOff, InputStorageType maxCutOff){
69  minCutOff_ = minCutOff;
70  maxCutOff_ = maxCutOff;
71  }
72 
73  protected:
74 
75  InputStorageType minCutOff_;
76  InputStorageType maxCutOff_;
77 
78  void GetBordersValid_(int& border_x, int& border_y) const {};
79 };
80 }
81 
82 #endif
void GetBordersValid_(int &border_x, int &border_y) const
virtual parent class for API definition of all (future) filters
Definition: FilterBase.hh:77
void SetCutOffs(InputStorageType minCutOff, InputStorageType maxCutOff)
perfoms a histogram equalization on a grey value image