37 m_img->grayscale(*new_img);
76 const size_t W =
m_img->getWidth();
77 const size_t H =
m_img->getHeight();
83 if (px < 0 || py < 0 || px > W || py > H)
95 return static_cast<double>(*
m_img->get_unsafe(px0, py0));
103 const int px0 = (int)floor(px);
104 const int px1 = (int)ceil(px);
105 const int py0 = (int)floor(py);
106 const int py1 = (int)ceil(py);
109 static_cast<double>(*
m_img->get_unsafe(px0, py0));
111 static_cast<double>(*
m_img->get_unsafe(px0, py1));
113 static_cast<double>(*
m_img->get_unsafe(px1, py0));
115 static_cast<double>(*
m_img->get_unsafe(px1, py1));
117 const double R1 = P11 * (px1 - px) +
119 const double R2 = P12 * (px1 - px) +
122 return R1 * (py1 - py) + R2 * (py - py0);
135 "The selected interpolation method is not supported in this " 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...
#define THROW_EXCEPTION(msg)
double m_pixel_size
width * pixel_size = (x1-x0)
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.
std::shared_ptr< CImage > Ptr
#define ASSERT_(f)
Defines an assertion mechanism.
This base provides a set of functions for maths stuff.
TInterpolationMethod
Interpolation methods for images.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TInterpolationMethod m_method
A class for storing images as grayscale or RGB bitmaps.
int round(const T value)
Returns the closer integer (int) to x.