RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_crop.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_CROP_HPP
14 #define IMAGE_CROP_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class crop : public image
21 {
22 public:
25 
26  crop(int row, int column, int height, int width, image *L)
27  : image(L), row(row), column(column), height(height), width(width) { }
28 
29  virtual double get(int i, int j, int k) const
30  {
31  if (0 <= i && i < height &&
32  0 <= j && j < width)
33 
34  return L->get(i + row, j + column, k);
35  else
36  return 0.0;
37  }
38 
39  virtual int get_height() const { return height; }
40  virtual int get_width () const { return width; }
41 
42  virtual void doc(std::ostream& out) const
43  {
44  out << "crop " << row << " " << column << " " << height << " " << width;
45  }
46 
47 private:
48  int row;
49  int column;
50  int height;
51  int width;
52 };
53 
54 //------------------------------------------------------------------------------
55 
56 #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.
Crop filter.
Definition: image_crop.hpp:20
image * L
Left child.
Definition: image.hpp:117
crop(int row, int column, int height, int width, image *L)
Crop image L to a size of height and width. Row and column give the location of the upper-left corner...
Definition: image_crop.hpp:26
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
virtual int get_width() const
Return the height of this image.
Definition: image_crop.hpp:40
virtual int get_height() const
Return the height of this image.
Definition: image_crop.hpp:39
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_crop.hpp:42