MRPT  1.9.9
CMappedImage.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://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 }
60 
std::shared_ptr< CImage > Ptr
Definition: img/CImage.h:132
This class encapsulates a MRPT Image and allows the sampling of individual pixels with sub-pixel accu...
Definition: CMappedImage.h:24
TInterpolationMethod m_method
Definition: CMappedImage.h:30
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.
double m_pixel_size
width * pixel_size = (x1-x0)
Definition: CMappedImage.h:29
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...
void changeCoordinates(double x0, double x1, double y0, double y1)
Changes the coordinates of the image (see constructor for the meaning)
GLenum GLint GLint y
Definition: glext.h:3538
GLint GLvoid * img
Definition: glext.h:3763
GLenum GLint x
Definition: glext.h:3538
TInterpolationMethod
Interpolation methods for images.
Definition: img/CImage.h:35
@ IMG_INTERP_LINEAR
Definition: img/CImage.h:37



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST