RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_offset.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_OFFSETS_HPP
14 #define IMAGE_OFFSETS_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class offset : public image
21 {
22 public:
25 
26  offset(int rows, int columns, int mode, image *L)
27  : image(L), rows(rows), columns(columns), mode(mode) { }
28 
29  virtual double get(int i, int j, int k) const
30  {
31  return L->get(wrap(i - rows, L->get_height(), mode & 1),
32  wrap(j - columns, L->get_width (), mode & 2), k);
33  }
34 
35  virtual void tweak(int a, int v)
36  {
37  if (a == 0) columns += v;
38  if (a == 1) rows += v;
39  }
40 
41  virtual void doc(std::ostream& out) const
42  {
43  out << "offset " << rows << " " << columns << " " << mode;
44  }
45 
46 private:
47  int rows;
48  int columns;
49  int mode;
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.
virtual void tweak(int a, int v)
Tweak image parameter a, changing the value by a factor of v.
Definition: image_offset.hpp:35
image * L
Left child.
Definition: image.hpp:117
offset(int rows, int columns, int mode, image *L)
Offset the pixels of L. Rows gives the vertical distance. Columns gives the horizontal distance...
Definition: image_offset.hpp:26
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
virtual int get_height() const
Return the height of this image.
Definition: image.hpp:46
Offset filter.
Definition: image_offset.hpp:20
virtual int get_width() const
Return the height of this image.
Definition: image.hpp:56
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_offset.hpp:41