RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_flatten.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_FLATTEN_HPP
14 #define IMAGE_FLATTEN_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class flatten : public image
21 {
22 public:
27 
28  flatten(double value, image *L) : image(L), value(value) { }
29 
30  virtual double get(int i, int j, int k) const
31  {
32  const int h = L->get_height() / 2;
33 
34  double l = M_PI_2 * double(h - i) / h;
35 
36  double y = sin(l) * value;
37  double x = cos(l);
38  double r = sqrt(x * x + y * y);
39 
40  return L->get(-h * (asin(y / r) - M_PI_2) / M_PI_2, j, k);
41  }
42 
43  virtual void tweak(int a, int v)
44  {
45  if (a == 0) value += 0.0001 * v;
46  }
47 
48  virtual void doc(std::ostream& out) const
49  {
50  out << "flatten " << value;
51  }
52 
53 private:
54  double value;
55 };
56 
57 //------------------------------------------------------------------------------
58 
59 #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_flatten.hpp:43
image * L
Left child.
Definition: image.hpp:117
Spherical flatten.
Definition: image_flatten.hpp:20
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
flatten(double value, image *L)
Account for variation in the flatness of the ellipse used to project spherical data. This filter user integer pixel locations for both input and output and performs no interpolation. This is preferable (for now) as it preserves the identity of data dropouts.
Definition: image_flatten.hpp:28
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_flatten.hpp:48