RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_choose.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_CHOOSE_HPP
14 #define IMAGE_CHOOSE_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class choose : public image
21 {
22 public:
26 
27  choose(int which, image *L, image *R) : image(L, R), which(which) { }
28 
29  virtual double get(int i, int j, int k) const
30  {
31  return which ? R->get(i, j, k) : L->get(i, j, k);
32  }
33 
34  virtual void tweak(int a, int v)
35  {
36  if (a == 0) which += v;
37  }
38 
39  virtual void doc(std::ostream& out) const
40  {
41  out << "choose " << which;
42  }
43 
44 private:
45  int which;
46 };
47 
48 //------------------------------------------------------------------------------
49 
50 #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
virtual void tweak(int a, int v)
Tweak image parameter a, changing the value by a factor of v.
Definition: image_choose.hpp:34
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_choose.hpp:39
Choose operator.
Definition: image_choose.hpp:20
image * R
Right child.
Definition: image.hpp:118
choose(int which, image *L, image *R)
Choose image L if which is 0 or image R if which is 1. This is akin to turning a layer on and off...
Definition: image_choose.hpp:27