MRPT  2.0.1
CMappedImage.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/img/CImage.h>
12 
13 namespace mrpt::img
14 {
15 /** This class encapsulates a MRPT Image and allows the sampling of individual
16  * pixels with sub-pixel accuracy and with a change of coordinates (eg, meters).
17  * Only work with graylevels (for convenience), so if a color image is passed
18  * it'll be passed first to grayscale.
19  *
20  * \sa CImage
21  * \ingroup mrpt_img_grp
22  */
24 {
25  protected:
27  double m_x0, m_x1, m_y0, m_y1;
28  /** width * pixel_size = (x1-x0) */
29  double m_pixel_size;
31 
32  public:
33  /** Constructor: Must pass an image (as a smart pointer) and the coordinates
34  * of the border
35  * \param img The image. A copy of the smart pointer is kept internally to
36  * this object.
37  * \param x0 Coordinate X of the left side (default: 0)
38  * \param x1 Coordinate X of the right side (or -1 to IMAGE_WIDTH-1)
39  * \param y0 Coordinate Y of the top side (default: 0)
40  * \param y1 Coordinate Y of the bottom side (or -1 to IMAGE_HEIGHT-1)
41  * \param method The interpolation method: It can be imNEAREST, imBILINEAR
42  * or imBICUBIC.
43  */
45  CImage::Ptr img, double x0 = 0, double x1 = -1, double y0 = 0,
46  double y1 = -1, TInterpolationMethod method = IMG_INTERP_LINEAR);
47 
48  /** Changes the coordinates of the image (see constructor for the meaning)
49  */
50  void changeCoordinates(double x0, double x1, double y0, double y1);
51 
52  /** Returns the interpolated pixel at the coordinates (x,y), in the range
53  * [0,255] (grayscale)
54  * If the point is out of the image, 0 is returned.
55  */
56  double getPixel(double x, double y) const;
57 
58 }; // End of class
59 } // namespace mrpt::img
void changeCoordinates(double x0, double x1, double y0, double y1)
Changes the coordinates of the image (see constructor for the meaning)
double getPixel(double x, double y) const
Returns the interpolated pixel at the coordinates (x,y), in the range [0,255] (grayscale) If the poin...
double m_pixel_size
width * pixel_size = (x1-x0)
Definition: CMappedImage.h:29
CMappedImage(CImage::Ptr img, double x0=0, double x1=-1, double y0=0, double y1=-1, TInterpolationMethod method=IMG_INTERP_LINEAR)
Constructor: Must pass an image (as a smart pointer) and the coordinates of the border.
TInterpolationMethod
Interpolation methods for images.
Definition: img/CImage.h:50
TInterpolationMethod m_method
Definition: CMappedImage.h:30
This class encapsulates a MRPT Image and allows the sampling of individual pixels with sub-pixel accu...
Definition: CMappedImage.h:23



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020