RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_threshold.hpp
1 // RAWK Copyright (C) 2014 Robert Kooima
2 //
3 // This program is free software: you can redistribute it and/or modify it
4 // under the terms of the GNU General Public License as published by the Free
5 // Software Foundation, either version 3 of the License, or (at your option)
6 // any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITH-
9 // OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 
13 #ifndef IMAGE_THRESHOLD_HPP
14 #define IMAGE_THRESHOLD_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class threshold : public image
21 {
22 public:
27 
28  threshold(double value, image *L) : image(L), value(value) { }
29 
30  virtual double get(int i, int j, int k) const
31  {
32  if (L->get(i, j, k) > value)
33  return 1.0;
34  else
35  return 0.0;
36  }
37 
38  virtual void tweak(int a, int v)
39  {
40  if (a == 0) value += 0.001 * v;
41  }
42 
43  virtual void doc(std::ostream& out) const
44  {
45  out << "threshold " << value;
46  }
47 
48 private:
49  double value;
50 };
51 
52 //------------------------------------------------------------------------------
53 
54 #endif
virtual double get(int i, int j, int k) const =0
Return the value of the sample at row i, column j, channel k.
image * L
Left child.
Definition: image.hpp:117
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
threshold(double value, image *L)
Compare the values of each sample of image L with value. Give 1 where L is greater than value and 0 e...
Definition: image_threshold.hpp:28
virtual void tweak(int a, int v)
Tweak image parameter a, changing the value by a factor of v.
Definition: image_threshold.hpp:38
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_threshold.hpp:43
Threshold filter.
Definition: image_threshold.hpp:20