36 m_img->grayscale(*new_img);
37 m_img = CImagePtr( new_img );
73 const size_t W =
m_img->getWidth();
74 const size_t H =
m_img->getHeight();
80 if (px<0 || py<0 || px>W || py>H) {
return 0; }
89 return static_cast<double>(*
m_img->get_unsafe(px0, py0));
97 const int px0 = (int)floor(px);
98 const int px1 = (int)ceil(px);
99 const int py0 = (int)floor(py);
100 const int py1 = (int)ceil(py);
102 const double P11 =
static_cast<double>(*
m_img->get_unsafe(px0, py0));
103 const double P12 =
static_cast<double>(*
m_img->get_unsafe(px0, py1));
104 const double P21 =
static_cast<double>(*
m_img->get_unsafe(px1, py0));
105 const double P22 =
static_cast<double>(*
m_img->get_unsafe(px1, py1));
107 const double R1 = P11*(px1-px) + P21*(px-px0) ;
108 const double R2 = P12*(px1-px) + P22*(px-px0) ;
110 return R1 * (py1-py) + R2 * (py-py0);
122 THROW_EXCEPTION(
"The selected interpolation method is not supported in this method.");
A class for storing images as grayscale or RGB bitmaps.
TInterpolationMethod m_method
double m_pixel_size
width * pixel_size = (x1-x0)
CMappedImage(CImagePtr 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 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)
TInterpolationMethod
Interpolation methods for images.
int round(const T value)
Returns the closer integer (int) to x.
#define THROW_EXCEPTION(msg)
This base provides a set of functions for maths stuff.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.