RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_reduce.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_REDUCE_HPP
14 #define IMAGE_REDUCE_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class reduce : public image
21 {
22 public:
27 
28  reduce(image *L) : image(L) { }
29 
30  virtual double get(int i, int j, int k) const
31  {
32  return (L->get(i * 2 + 0, j * 2 + 0, k) +
33  L->get(i * 2 + 0, j * 2 + 1, k) +
34  L->get(i * 2 + 1, j * 2 + 0, k) +
35  L->get(i * 2 + 1, j * 2 + 1, k)) / 4.0;
36  }
37 
38  virtual int get_height() const { return L->get_height() / 2; }
39  virtual int get_width () const { return L->get_width () / 2; }
40 
41  virtual void doc(std::ostream& out) const
42  {
43  out << "reduce";
44  }
45 };
46 
47 //------------------------------------------------------------------------------
48 
49 #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
50% down-sample filter
Definition: image_reduce.hpp:20
virtual int get_height() const
Return the height of this image.
Definition: image.hpp:46
virtual int get_width() const
Return the height of this image.
Definition: image_reduce.hpp:39
reduce(image *L)
Apply a 2-by-2 box-filtered down-sampling to image L. The height and width of the result will be exac...
Definition: image_reduce.hpp:28
virtual int get_width() const
Return the height of this image.
Definition: image.hpp:56
virtual int get_height() const
Return the height of this image.
Definition: image_reduce.hpp:38
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_reduce.hpp:41