Main MRPT website > C++ reference
MRPT logo
CMappedImage.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CMappedImage_H
29 #define CMappedImage_H
30 
31 #include <mrpt/utils/CImage.h>
32 
33 namespace mrpt
34 {
35  namespace utils
36  {
37  /** This class encapsulates a MRPT Image and allows the sampling of individual pixels with sub-pixel accuracy and with a change of coordinates (eg, meters).
38  * Only work with graylevels (for convenience), so if a color image is passed it'll be passed first to grayscale.
39  *
40  * \sa CImage
41  * \ingroup mrpt_base_grp
42  */
44  {
45  protected:
47  double m_x0,m_x1, m_y0, m_y1;
48  double m_pixel_size; //!< width * pixel_size = (x1-x0)
50 
51  public:
52  /** Constructor: Must pass an image (as a smart pointer) and the coordinates of the border
53  * \param img The image. A copy of the smart pointer is kept internally to this object.
54  * \param x0 Coordinate X of the left side (default: 0)
55  * \param x1 Coordinate X of the right side (or -1 to IMAGE_WIDTH-1)
56  * \param y0 Coordinate Y of the top side (default: 0)
57  * \param y1 Coordinate Y of the bottom side (or -1 to IMAGE_HEIGHT-1)
58  * \param method The interpolation method: It can be imNEAREST, imBILINEAR or imBICUBIC.
59  */
60  CMappedImage( CImagePtr img, double x0=0, double x1=-1, double y0=0, double y1=-1, TInterpolationMethod method = IMG_INTERP_LINEAR );
61 
62  /** Changes the coordinates of the image (see constructor for the meaning) */
63  void changeCoordinates(double x0, double x1, double y0, double y1);
64 
65  /** Returns the interpolated pixel at the coordinates (x,y), in the range [0,255] (grayscale)
66  * If the point is out of the image, 0 is returned.
67  */
68  double getPixel(double x,double y ) const;
69 
70 
71  }; // End of class
72 
73 
74  } // end of namespace utils
75 
76 } // end of namespace mrpt
77 
78 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013