MRPT  2.0.1
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
mrpt::img::CImage Class Reference

Detailed Description

A class for storing images as grayscale or RGB bitmaps.

I/O is supported as:

Additional notes:

Some functions are implemented in MRPT with highly optimized SSE2/SSE3 routines, in suitable platforms and compilers. To see the list of optimizations refer to sse_optimizations, falling back to default OpenCV methods where unavailable.

For computer vision functions that use CImage as its image data type, see mrpt::vision.

See also
mrpt::vision, mrpt::vision::CFeatureExtractor, mrpt::vision::CImagePyramid, CSerializable, CCanvas

Definition at line 148 of file img/CImage.h.

#include <mrpt/img/CImage.h>

Inheritance diagram for mrpt::img::CImage:

Classes

struct  Impl
 

Public Types

enum  TPenStyle {
  psSolid = 0, psDash, psDot, psDashDot,
  psDashDotDot
}
 Definition of pen styles. More...
 

Public Member Functions

void getAsIplImage (IplImage *dest) const
 (DEPRECATED, DO NOT USE - Kept here only to interface opencv 2.4) More...
 
virtual mxArraywriteToMatlab () const
 Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More...
 
void rectangle (int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1)
 Draws a rectangle (an empty rectangle, without filling) More...
 
void triangle (int x0, int y0, int size, const mrpt::img::TColor color, bool inferior=true, unsigned int width=1)
 Draws a triangle. More...
 
virtual void filledRectangle (int x0, int y0, int x1, int y1, const mrpt::img::TColor color)
 Draws a filled rectangle. More...
 
virtual void textOut (int x0, int y0, const std::string &str, const mrpt::img::TColor color)
 Renders 2D text using bitmap fonts. More...
 
virtual void selectTextFont (const std::string &fontName)
 Select the current font used when drawing text. More...
 
virtual void drawImage (int x, int y, const mrpt::img::CImage &img, float rotation, float scale)
 Draws an image as a bitmap at a given position, with some custom scale and rotation changes. More...
 
void drawMark (int x0, int y0, const mrpt::img::TColor color, char type, int size=5, unsigned int width=1)
 Draw a mark. More...
 
void ellipseGaussian (const mrpt::math::CMatrixFixed< double, 2, 2 > &cov2D, const double mean_x, const double mean_y, double confIntervalStds=2, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1, int nEllipsePoints=20)
 Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution. More...
 
template<class FEATURELIST >
void drawFeaturesSimple (const FEATURELIST &list, const TColor &color=TColor::red(), const int cross_size=5)
 Draws a set of marks onto the image, given a generic container of entities having just "x" and "y" fields. More...
 
template<class FEATURELIST >
void drawFeatures (const FEATURELIST &list, const TColor &color=TColor::red(), const bool showIDs=false, const bool showResponse=false, const bool showScale=false, const char marker='+')
 Draws a set of marks (or scaled circles for features with scale) onto the image, given a generic container of features. More...
 
Constructors & destructor
 CImage ()
 Default constructor: initialize to empty image. More...
 
 CImage (unsigned int width, unsigned int height, TImageChannels nChannels=CH_RGB)
 Constructor for a given image size and type. More...
 
 CImage (const CImage &other_img, ctor_CImage_ref_or_gray)
 Fast constructor of a grayscale version of another image, making a shallow copy from the original image if it already was grayscale, or otherwise creating a new grayscale image and converting the original image into it. More...
 
 CImage (const cv::Mat &img, copy_type_t copy_type)
 Constructor from a cv::Mat image, making or not a deep copy of the data. More...
 
 CImage (const CImage &img, copy_type_t copy_type)
 Constructor from another CImage, making or not a deep copy of the data. More...
 
Manipulate the image contents or size, various computer-vision

methods (image filters, undistortion, etc.)

void clear ()
 Resets the image to the state after a default ctor. More...
 
void resize (std::size_t width, std::size_t height, TImageChannels nChannels, PixelDepth depth=PixelDepth::D8U)
 Changes the size of the image, erasing previous contents (does NOT scale its current content, for that, see scaleImage). More...
 
PixelDepth getPixelDepth () const
 
void scaleImage (CImage &out_img, unsigned int width, unsigned int height, TInterpolationMethod interp=IMG_INTERP_CUBIC) const
 Scales this image to a new size, interpolating as needed, saving the new image in a different output object, or operating in-place if out_img==this. More...
 
void rotateImage (CImage &out_img, double ang, unsigned int cx, unsigned int cy, double scale=1.0) const
 Rotates the image by the given angle around the given center point, with an optional scale factor. More...
 
void setPixel (int x, int y, size_t color) override
 Changes the value of the pixel (x,y). More...
 
void line (int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) override
 Draws a line. More...
 
void drawCircle (int x, int y, int radius, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1) override
 Draws a circle of a given radius. More...
 
void drawImage (int x, int y, const mrpt::img::CImage &img) override
 Draws an image as a bitmap at a given position. More...
 
void equalizeHist (CImage &out_img) const
 Equalize the image histogram, saving the new image in the given output object. More...
 
CImage scaleHalf (TInterpolationMethod interp) const
 Returns a new image scaled down to half its original size. More...
 
bool scaleHalf (CImage &out_image, TInterpolationMethod interp) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
CImage scaleDouble (TInterpolationMethod interp) const
 Returns a new image scaled up to double its original size. More...
 
void scaleDouble (CImage &out_image, TInterpolationMethod interp) const
 
void update_patch (const CImage &patch, const unsigned int col, const unsigned int row)
 Update a part of this image with the "patch" given as argument. More...
 
void extract_patch (CImage &patch, const unsigned int col=0, const unsigned int row=0, const unsigned int width=1, const unsigned int height=1) const
 Extract a patch from this image, saveing it into "patch" (its previous contents will be overwritten). More...
 
float correlate (const CImage &img2int, int width_init=0, int height_init=0) const
 Computes the correlation coefficient (returned as val), between two images This function use grayscale images only img1, img2 must be same size (by AJOGD @ DEC-2006) More...
 
void cross_correlation_FFT (const CImage &in_img, math::CMatrixFloat &out_corr, int u_search_ini=-1, int v_search_ini=-1, int u_search_size=-1, int v_search_size=-1, float biasThisImg=0, float biasInImg=0) const
 Computes the correlation matrix between this image and another one. More...
 
void normalize ()
 Optimize the brightness range of an image without using histogram Only for one channel images. More...
 
void flipVertical ()
 Flips the image vertically. More...
 
void flipHorizontal ()
 Flips the image horizontally. More...
 
void swapRB ()
 Swaps red and blue channels. More...
 
void undistort (CImage &out_img, const mrpt::img::TCamera &cameraParams) const
 Undistort the image according to some camera parameters, and returns an output undistorted image. More...
 
void rectifyImageInPlace (void *mapX, void *mapY)
 Rectify an image (undistorts and rectification) from a stereo pair according to a pair of precomputed rectification maps. More...
 
void filterMedian (CImage &out_img, int W=3) const
 Filter the image with a Median filter with a window size WxW, returning the filtered image in out_img. More...
 
void filterGaussian (CImage &out_img, int W=3, int H=3, double sigma=1.0) const
 Filter the image with a Gaussian filter with a window size WxH, replacing "this" image by the filtered one. More...
 
bool drawChessboardCorners (std::vector< TPixelCoordf > &cornerCoords, unsigned int check_size_x, unsigned int check_size_y, unsigned int lines_width=1, unsigned int circles_radius=4)
 Draw onto this image the detected corners of a chessboard. More...
 
void joinImagesHorz (const CImage &im1, const CImage &im2)
 Joins two images side-by-side horizontally. More...
 
float KLT_response (const unsigned int x, const unsigned int y, const unsigned int half_window_size) const
 Compute the KLT response at a given pixel (x,y) - Only for grayscale images (for efficiency it avoids converting to grayscale internally). More...
 
Copy, move & swap operations
void setFromImageReadOnly (const CImage &o)
 
CImage makeShallowCopy () const
 Returns a shallow copy of the original image. More...
 
CImage makeDeepCopy () const
 Returns a deep copy of this image. More...
 
void copyFromForceLoad (const CImage &o)
 Copies from another image (shallow copy), and, if it is externally stored, the image file will be actually loaded into memory in "this" object. More...
 
void copyFastFrom (CImage &o)
 Moves an image from another object, erasing the origin image in the process. More...
 
void loadFromIplImage (const IplImage *iplImage, copy_type_t c=DEEP_COPY)
 Assigns from an image in IplImage format. More...
 
void setFromIplImageReadOnly (IplImage *iplImage)
 
void swap (CImage &o)
 Efficiently swap of two images. More...
 
Access to image contents (OpenCV data structure, and raw pixels)
void asCvMat (cv::Mat &out_img, copy_type_t copy_type) const
 Makes a shallow or deep copy of this image into the provided cv::Mat. More...
 
template<typename CV_MAT >
CV_MAT asCvMat (copy_type_t copy_type) const
 
cv::Mat & asCvMatRef ()
 Get a reference to the internal cv::Mat, which can be resized, etc. More...
 
const cv::Mat & asCvMatRef () const
 
uint8_t * get_unsafe (unsigned int col, unsigned int row, uint8_t channel=0) const
 Access to pixels without checking boundaries - Use normally the () operator better, which checks the coordinates. More...
 
template<typename T >
const T & at (unsigned int col, unsigned int row, unsigned int channel=0) const
 Access to pixels without checking boundaries, and doing a reinterpret_cast<> of the data as the given type. More...
 
template<typename T >
T & at (unsigned int col, unsigned int row, unsigned int channel=0)
 
template<typename T >
const T * ptr (unsigned int col, unsigned int row, unsigned int channel=0) const
 Returns a pointer to a given pixel, without checking for boundaries. More...
 
template<typename T >
T * ptr (unsigned int col, unsigned int row, unsigned int channel=0)
 
template<typename T >
const T * ptrLine (unsigned int row) const
 Returns a pointer to the first pixel of the given line. More...
 
template<typename T >
T * ptrLine (unsigned int row)
 
float getAsFloat (unsigned int col, unsigned int row, unsigned int channel) const
 Returns the contents of a given pixel at the desired channel, in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image. More...
 
float getAsFloat (unsigned int col, unsigned int row) const
 Returns the contents of a given pixel (for gray-scale images, in color images the gray scale equivalent is computed for the pixel), in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image. More...
 
unsigned char * operator() (unsigned int col, unsigned int row, unsigned int channel=0) const
 Returns a pointer to a given pixel information. More...
 
Query image properties
size_t getWidth () const override
 Returns the width of the image in pixels. More...
 
size_t getHeight () const override
 Returns the height of the image in pixels. More...
 
void getSize (TImageSize &s) const
 Return the size of the image. More...
 
TImageSize getSize () const
 Return the size of the image. More...
 
size_t getRowStride () const
 Returns the row stride of the image: this is the number of bytes between two consecutive rows. More...
 
std::string getChannelsOrder () const
 As of mrpt 2.0.0, this returns either "GRAY" or "BGR". More...
 
float getMaxAsFloat () const
 Return the maximum pixel value of the image, as a float value in the range [0,1]. More...
 
bool isColor () const
 Returns true if the image is RGB, false if it is grayscale. More...
 
bool isEmpty () const
 Returns true if the object is in the state after default constructor. More...
 
bool isOriginTopLeft () const
 Returns true (as of MRPT v2.0.0, it's fixed) More...
 
TImageChannels getChannelCount () const
 Returns the number of channels, typically 1 (GRAY) or 3 (RGB) More...
 
void getAsMatrix (mrpt::math::CMatrixFloat &outMatrix, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1, bool normalize_01=true) const
 Returns the image as a matrix with pixel grayscale values in the range [0,1]. More...
 
void getAsMatrix (mrpt::math::CMatrix_u8 &outMatrix, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1) const
 
void getAsRGBMatrices (mrpt::math::CMatrixFloat &outMatrixR, mrpt::math::CMatrixFloat &outMatrixG, mrpt::math::CMatrixFloat &outMatrixB, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1) const
 Returns the image as RGB matrices with pixel values in the range [0,1]. More...
 
void getAsRGBMatrices (mrpt::math::CMatrix_u8 &outMatrixR, mrpt::math::CMatrix_u8 &outMatrixG, mrpt::math::CMatrix_u8 &outMatrixB, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1) const
 
void getAsMatrixTiled (mrpt::math::CMatrixFloat &outMatrix) const
 Returns the image as a matrix, where the image is "tiled" (repeated) the required number of times to fill the entire size of the matrix on input. More...
 
Color/Grayscale conversion
CImage grayscale () const
 Returns a grayscale version of the image, or a shallow copy of itself if it is already a grayscale image. More...
 
bool grayscale (CImage &ret) const
 
CImage colorImage () const
 Returns a color (RGB) version of the grayscale image, or a shallow copy of itself if it is already a color image. More...
 
void colorImage (CImage &ret) const
 
RTTI classes and functions for polymorphic hierarchies
mrpt::rtti::CObject::Ptr duplicateGetSmartPtr () const
 Makes a deep copy of the object and returns a smart pointer to it. More...
 

Static Public Member Functions

Behavior-changing global flags
static void DISABLE_ZIP_COMPRESSION (bool val)
 By default, when storing images through the CSerializable interface, grayscale images will be ZIP compressed if they are larger than 16Kb: this flag can be turn on to disable ZIP compression and gain speed versus occupied space. More...
 
static bool DISABLE_ZIP_COMPRESSION ()
 
static void DISABLE_JPEG_COMPRESSION (bool val)
 By default, when storing images through the CSerializable interface, RGB images are JPEG-compressed to save space. More...
 
static bool DISABLE_JPEG_COMPRESSION ()
 
static void SERIALIZATION_JPEG_QUALITY (int q)
 Unless DISABLE_JPEG_COMPRESSION=true, this sets the JPEG quality (range 1-100) of serialized RGB images. More...
 
static int SERIALIZATION_JPEG_QUALITY ()
 

Protected Member Functions

void makeSureImageIsLoaded () const
 Checks if the image is of type "external storage", and if so and not loaded yet, load it. More...
 
uint8_t * internal_get (int col, int row, uint8_t channel=0) const
 
void internal_fromIPL (const IplImage *iplImage, copy_type_t c)
 
CSerializable virtual methods
uint8_t serializeGetVersion () const override
 Must return the current versioning number of the object. More...
 
void serializeTo (mrpt::serialization::CArchive &out) const override
 Pure virtual method for writing (serializing) to an abstract archive. More...
 
void serializeFrom (mrpt::serialization::CArchive &in, uint8_t serial_version) override
 Pure virtual method for reading (deserializing) from an abstract archive. More...
 
CSerializable virtual methods
virtual void serializeTo (CSchemeArchiveBase &out) const
 Virtual method for writing (serializing) to an abstract schema based archive. More...
 
virtual void serializeFrom (CSchemeArchiveBase &in)
 Virtual method for reading (deserializing) from an abstract schema based archive. More...
 

Protected Attributes

std::string m_selectedFont {"9x15"}
 The selected font name. More...
 
const uint32_t * m_selectedFontBitmaps {nullptr}
 Direct access to character bitmaps. More...
 
Data members
mrpt::pimpl< Implm_impl
 
bool m_imgIsExternalStorage {false}
 Set to true only when using setExternalStorage. More...
 
std::string m_externalFile
 The file name of a external storage image. More...
 

RTTI stuff

using Ptr = std::shared_ptr< mrpt::img ::CImage >
 
using ConstPtr = std::shared_ptr< const mrpt::img ::CImage >
 
using UniquePtr = std::unique_ptr< mrpt::img ::CImage >
 
using ConstUniquePtr = std::unique_ptr< const mrpt::img ::CImage >
 
static const mrpt::rtti::TRuntimeClassId runtimeClassId
 
static constexpr const char * className = "mrpt::img" "::" "CImage"
 
static const mrpt::rtti::TRuntimeClassId_GetBaseClass ()
 
static constexpr auto getClassName ()
 
static const mrpt::rtti::TRuntimeClassIdGetRuntimeClassIdStatic ()
 
static std::shared_ptr< CObjectCreateObject ()
 
template<typename... Args>
static Ptr Create (Args &&... args)
 
template<typename Alloc , typename... Args>
static Ptr CreateAlloc (const Alloc &alloc, Args &&... args)
 
template<typename... Args>
static UniquePtr CreateUnique (Args &&... args)
 
virtual const mrpt::rtti::TRuntimeClassIdGetRuntimeClass () const override
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::rtti::CObjectclone () const override
 Returns a deep copy (clone) of the object, indepently of its class. More...
 

External storage-mode methods

static const std::string & getImagesPathBase ()
 By default, ".". More...
 
static void setImagesPathBase (const std::string &path)
 
void setExternalStorage (const std::string &fileName) noexcept
 By using this method the image is marked as referenced to an external file, which will be loaded only under demand. More...
 
bool isExternallyStored () const noexcept
 See setExternalStorage(). More...
 
std::string getExternalStorageFile () const noexcept
 Only if isExternallyStored() returns true. More...
 
void getExternalStorageFileAbsolutePath (std::string &out_path) const
 Only if isExternallyStored() returns true. More...
 
std::string getExternalStorageFileAbsolutePath () const
 Only if isExternallyStored() returns true. More...
 
void forceLoad () const
 For external storage image objects only, this method makes sure the image is loaded in memory. More...
 
void unload () const noexcept
 For external storage image objects only, this method unloads the image from memory (or does nothing if already unloaded). More...
 

Set, load & save methods

static bool loadTGA (const std::string &fileName, mrpt::img::CImage &out_RGB, mrpt::img::CImage &out_alpha)
 Loads a TGA true-color RGBA image as two CImage objects, one for the RGB channels plus a separate gray-level image with A channel. More...
 
void loadFromMemoryBuffer (unsigned int width, unsigned int height, bool color, unsigned char *rawpixels, bool swapRedBlue=false)
 Reads the image from raw pixels buffer in memory. More...
 
void loadFromMemoryBuffer (unsigned int width, unsigned int height, unsigned int bytesPerRow, unsigned char *red, unsigned char *green, unsigned char *blue)
 Reads a color image from three raw pixels buffers in memory. More...
 
template<typename MAT >
void setFromMatrix (const MAT &m, bool matrix_is_normalized=true)
 Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,1] (normalized=true) or [0,255] (normalized=false) Matrix indexes are assumed to be in this order: M(row,column) More...
 
template<typename MAT >
void setFromRGBMatrices (const MAT &r, const MAT &g, const MAT &b, bool matrix_is_normalized=true)
 Set the image from RGB matrices, given the pixels in the range [0,1] (normalized=true) or [0,255] (normalized=false) Matrix indexes are assumed to be in this order: M(row,column) More...
 
void loadFromStreamAsJPEG (mrpt::io::CStream &in)
 Reads the image from a binary stream containing a binary jpeg file. More...
 
bool loadFromFile (const std::string &fileName, int isColor=-1)
 Load image from a file, whose format is determined from the extension (internally uses OpenCV). More...
 
bool loadFromXPM (const char *const *xpm_array, bool swap_rb=true)
 Loads the image from an XPM array, as #include'd from a ".xpm" file. More...
 
bool saveToFile (const std::string &fileName, int jpeg_quality=95) const
 Save the image to a file, whose format is determined from the extension (internally uses OpenCV). More...
 
void saveToStreamAsJPEG (mrpt::io::CStream &out, const int jpeg_quality=95) const
 Save image to binary stream as a JPEG (.jpg) compressed format. More...
 

Member Typedef Documentation

◆ ConstPtr

using mrpt::img::CImage::ConstPtr = std::shared_ptr<const mrpt::img :: CImage >

Definition at line 150 of file img/CImage.h.

◆ ConstUniquePtr

using mrpt::img::CImage::ConstUniquePtr = std::unique_ptr<const mrpt::img :: CImage >

Definition at line 150 of file img/CImage.h.

◆ Ptr

A type for the associated smart pointer

Definition at line 150 of file img/CImage.h.

◆ UniquePtr

using mrpt::img::CImage::UniquePtr = std::unique_ptr< mrpt::img :: CImage >

Definition at line 150 of file img/CImage.h.

Member Enumeration Documentation

◆ TPenStyle

Definition of pen styles.

Enumerator
psSolid 
psDash 
psDot 
psDashDot 
psDashDotDot 

Definition at line 55 of file CCanvas.h.

Constructor & Destructor Documentation

◆ CImage() [1/5]

CImage::CImage ( )

Default constructor: initialize to empty image.

It's an error trying to access the image in such a state (except reading the image width/height, which are both zero). Either call resize(), assign from another image, load from disk, deserialize from an archive, etc. to properly initialize the image.

Definition at line 159 of file CImage.cpp.

Referenced by CImage(), and clear().

Here is the caller graph for this function:

◆ CImage() [2/5]

CImage::CImage ( unsigned int  width,
unsigned int  height,
TImageChannels  nChannels = CH_RGB 
)

Constructor for a given image size and type.

Examples:

CImage img1(width, height, CH_GRAY ); // Grayscale image (8U1C)
CImage img2(width, height, CH_RGB ); // RGB image (8U3C)

Definition at line 162 of file CImage.cpp.

References MRPT_END, MRPT_START, and resize().

Here is the call graph for this function:

◆ CImage() [3/5]

mrpt::img::CImage::CImage ( const CImage other_img,
ctor_CImage_ref_or_gray   
)
inline

Fast constructor of a grayscale version of another image, making a shallow copy from the original image if it already was grayscale, or otherwise creating a new grayscale image and converting the original image into it.

Example of usage:

void my_func(const CImage &in_img) {
const CImage gray_img(in_img, FAST_REF_OR_CONVERT_TO_GRAY);
// We can now operate on "gray_img" being sure it's in grayscale.
}

Definition at line 190 of file img/CImage.h.

References CImage(), grayscale(), and isColor().

Here is the call graph for this function:

◆ CImage() [4/5]

CImage::CImage ( const cv::Mat &  img,
copy_type_t  copy_type 
)

Constructor from a cv::Mat image, making or not a deep copy of the data.

Definition at line 184 of file CImage.cpp.

References mrpt::img::DEEP_COPY, m_impl, MRPT_END, and MRPT_START.

◆ CImage() [5/5]

CImage::CImage ( const CImage img,
copy_type_t  copy_type 
)

Constructor from another CImage, making or not a deep copy of the data.

Definition at line 196 of file CImage.cpp.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::rtti::TRuntimeClassId* mrpt::img::CImage::_GetBaseClass ( )
staticprotected

◆ asCvMat() [1/2]

void CImage::asCvMat ( cv::Mat &  out_img,
copy_type_t  copy_type 
) const

◆ asCvMat() [2/2]

template<typename CV_MAT >
CV_MAT mrpt::img::CImage::asCvMat ( copy_type_t  copy_type) const
inline

Definition at line 540 of file img/CImage.h.

References asCvMat().

Here is the call graph for this function:

◆ asCvMatRef() [1/2]

cv::Mat & CImage::asCvMatRef ( )

◆ asCvMatRef() [2/2]

const cv::Mat & CImage::asCvMatRef ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 237 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ at() [1/2]

template<typename T >
const T& mrpt::img::CImage::at ( unsigned int  col,
unsigned int  row,
unsigned int  channel = 0 
) const
inline

Access to pixels without checking boundaries, and doing a reinterpret_cast<> of the data as the given type.

See also
The CImage::operator() which does check for coordinate limits.

Definition at line 567 of file img/CImage.h.

References internal_get().

Referenced by mrpt::detectors::CFaceDetection::checkIfDiagonalSurface(), mrpt::detectors::CFaceDetection::checkIfDiagonalSurface2(), mrpt::detectors::CFaceDetection::checkIfFacePlaneCov(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), mrpt::vision::computeSAD(), expect_identical(), mrpt::detectors::CFaceDetection::experimental_calcHist(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), fillImagePseudoRandom(), mrpt::vision::CFeatureExtraction::internal_computeSpinImageDescriptors(), mrpt::vision::matchFeatures(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at() [2/2]

template<typename T >
T& mrpt::img::CImage::at ( unsigned int  col,
unsigned int  row,
unsigned int  channel = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 574 of file img/CImage.h.

References internal_get().

Here is the call graph for this function:

◆ clear()

void CImage::clear ( )

Resets the image to the state after a default ctor.

Accessing the image after will throw an exception, unless it is formerly initialized somehow: loading an image from disk, calling rezize(), etc.

Definition at line 1565 of file CImage.cpp.

References CImage().

Referenced by find_chessboard_corners_multiple(), internal_fromIPL(), rectifyImageInPlace(), and serializeFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

virtual mrpt::rtti::CObject* mrpt::img::CImage::clone ( ) const
overridevirtual

Returns a deep copy (clone) of the object, indepently of its class.

Implements mrpt::rtti::CObject.

◆ colorImage() [1/2]

CImage CImage::colorImage ( ) const

Returns a color (RGB) version of the grayscale image, or a shallow copy of itself if it is already a color image.

See also
grayscale

Definition at line 1861 of file CImage.cpp.

Referenced by mrpt::vision::checkerBoardStereoCalibration(), mrpt::gui::MRPTImage2wxImage(), mrpt::gui::CDisplayWindow::showImageAndPoints(), and mrpt::gui::CDisplayWindow::showTiledImageAndPoints().

Here is the caller graph for this function:

◆ colorImage() [2/2]

void CImage::colorImage ( CImage ret) const

Definition at line 1868 of file CImage.cpp.

References mrpt::img::CH_RGB, getHeight(), getWidth(), isColor(), m_impl, and resize().

Here is the call graph for this function:

◆ copyFastFrom()

void mrpt::img::CImage::copyFastFrom ( CImage o)
inline

Moves an image from another object, erasing the origin image in the process.

See also
operator =

Definition at line 506 of file img/CImage.h.

◆ copyFromForceLoad()

void CImage::copyFromForceLoad ( const CImage o)

Copies from another image (shallow copy), and, if it is externally stored, the image file will be actually loaded into memory in "this" object.

See also
operator =
Exceptions
CExceptionExternalImageNotFoundIf the external image couldn't be loaded.

Definition at line 178 of file CImage.cpp.

References forceLoad().

Here is the call graph for this function:

◆ correlate()

float CImage::correlate ( const CImage img2int,
int  width_init = 0,
int  height_init = 0 
) const

Computes the correlation coefficient (returned as val), between two images This function use grayscale images only img1, img2 must be same size (by AJOGD @ DEC-2006)

Definition at line 1179 of file CImage.cpp.

References getHeight(), getWidth(), makeSureImageIsLoaded(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ Create()

template<typename... Args>
static Ptr mrpt::img::CImage::Create ( Args &&...  args)
inlinestatic

Definition at line 150 of file img/CImage.h.

◆ CreateAlloc()

template<typename Alloc , typename... Args>
static Ptr mrpt::img::CImage::CreateAlloc ( const Alloc &  alloc,
Args &&...  args 
)
inlinestatic

Definition at line 150 of file img/CImage.h.

◆ CreateObject()

static std::shared_ptr<CObject> mrpt::img::CImage::CreateObject ( )
static

◆ CreateUnique()

template<typename... Args>
static UniquePtr mrpt::img::CImage::CreateUnique ( Args &&...  args)
inlinestatic

Definition at line 150 of file img/CImage.h.

◆ cross_correlation_FFT()

void CImage::cross_correlation_FFT ( const CImage in_img,
math::CMatrixFloat out_corr,
int  u_search_ini = -1,
int  v_search_ini = -1,
int  u_search_size = -1,
int  v_search_size = -1,
float  biasThisImg = 0,
float  biasInImg = 0 
) const

Computes the correlation matrix between this image and another one.

This implementation uses the 2D FFT for achieving reduced computation time.

Parameters
in_imgThe "patch" image, which must be equal, or smaller than "this" image. This function supports gray-scale (1 channel only) images.
u_search_iniThe "x" coordinate of the search window.
v_search_iniThe "y" coordinate of the search window.
u_search_sizeThe width of the search window.
v_search_sizeThe height of the search window.
out_corrThe output for the correlation matrix, which will be "u_search_size" x "v_search_size"
biasThisImgThis optional parameter is a fixed "bias" value to be substracted to the pixels of "this" image before performing correlation.
biasInImgThis optional parameter is a fixed "bias" value to be substracted to the pixels of "in_img" image before performing correlation. Note: By default, the search area is the whole (this) image. (by JLBC @ JAN-2006)
See also
cross_correlation

Definition at line 1435 of file CImage.cpp.

References ASSERT_, mrpt::math::dft2_complex(), getAsMatrix(), getHeight(), getWidth(), mrpt::math::idft2_complex(), makeSureImageIsLoaded(), MRPT_END, MRPT_START, mrpt::math::CMatrixDynamic< T >::setSize(), and mrpt::square().

Referenced by mrpt::slam::CGridMapAligner::AlignPDF_correlation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DISABLE_JPEG_COMPRESSION() [1/2]

void CImage::DISABLE_JPEG_COMPRESSION ( bool  val)
static

By default, when storing images through the CSerializable interface, RGB images are JPEG-compressed to save space.

If for some reason you prefer storing RAW image data, disable this feature by setting this flag to true. (Default = true)

Definition at line 53 of file CImage.cpp.

References DISABLE_JPEG_COMPRESSION_value, and val.

◆ DISABLE_JPEG_COMPRESSION() [2/2]

bool CImage::DISABLE_JPEG_COMPRESSION ( )
static

Definition at line 57 of file CImage.cpp.

References DISABLE_JPEG_COMPRESSION_value.

Referenced by serializeTo().

Here is the caller graph for this function:

◆ DISABLE_ZIP_COMPRESSION() [1/2]

static void mrpt::img::CImage::DISABLE_ZIP_COMPRESSION ( bool  val)
static

By default, when storing images through the CSerializable interface, grayscale images will be ZIP compressed if they are larger than 16Kb: this flag can be turn on to disable ZIP compression and gain speed versus occupied space.

(Default = false)

◆ DISABLE_ZIP_COMPRESSION() [2/2]

static bool mrpt::img::CImage::DISABLE_ZIP_COMPRESSION ( )
static

◆ drawChessboardCorners()

bool CImage::drawChessboardCorners ( std::vector< TPixelCoordf > &  cornerCoords,
unsigned int  check_size_x,
unsigned int  check_size_y,
unsigned int  lines_width = 1,
unsigned int  circles_radius = 4 
)

Draw onto this image the detected corners of a chessboard.

The length of cornerCoords must be the product of the two check_sizes.

Parameters
cornerCoords[IN] The pixel coordinates of all the corners.
check_size_x[IN] The number of squares, in the X direction
check_size_y[IN] The number of squares, in the Y direction
Returns
false if the length of cornerCoords is inconsistent (nothing is drawn then).
See also
mrpt::vision::findChessboardCorners

Definition at line 1799 of file CImage.cpp.

References mrpt::img::TColor::blue(), check_size_x, check_size_y, mrpt::format(), m_impl, mrpt::img::CCanvas::selectTextFont(), and mrpt::img::CCanvas::textOut().

Referenced by mrpt::vision::checkerBoardStereoCalibration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawCircle()

void CImage::drawCircle ( int  x,
int  y,
int  radius,
const mrpt::img::TColor color = mrpt::img::TColor(255, 255, 255),
unsigned int  width = 1 
)
overridevirtual

Draws a circle of a given radius.

Parameters
xThe center - x coordinate in pixels.
yThe center - y coordinate in pixels.
radiusThe radius - in pixels.
colorThe color of the circle.
widthThe desired width of the line (this is IGNORED in this virtual class)

Reimplemented from mrpt::img::CCanvas.

Definition at line 1130 of file CImage.cpp.

References mrpt::img::TColor::B, mrpt::img::TColor::G, m_impl, makeSureImageIsLoaded(), and mrpt::img::TColor::R.

Here is the call graph for this function:

◆ drawFeatures()

template<class FEATURELIST >
void mrpt::img::CCanvas::drawFeatures ( const FEATURELIST &  list,
const TColor color = TColor::red(),
const bool  showIDs = false,
const bool  showResponse = false,
const bool  showScale = false,
const char  marker = '+' 
)
inlineinherited

Draws a set of marks (or scaled circles for features with scale) onto the image, given a generic container of features.

The class of FEATURELIST can be:

See also
drawFeaturesSimple

Definition at line 280 of file CCanvas.h.

References mrpt::img::CCanvas::drawCircle(), mrpt::img::CCanvas::drawMark(), mrpt::format(), mrpt::img::TColor::red(), mrpt::round(), and mrpt::img::CCanvas::textOut().

Referenced by mrpt::gui::CDisplayWindow::showImageAndPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawFeaturesSimple()

template<class FEATURELIST >
void mrpt::img::CCanvas::drawFeaturesSimple ( const FEATURELIST &  list,
const TColor color = TColor::red(),
const int  cross_size = 5 
)
inlineinherited

Draws a set of marks onto the image, given a generic container of entities having just "x" and "y" fields.

The class of FEATURELIST can be, for example, std::vector<mrpt::math::TPoint2D>, std::vector<TPixelCoordsf> or mrpt::vision::CFeatureList

See also
drawFeatures

Definition at line 259 of file CCanvas.h.

References mrpt::img::CCanvas::drawMark(), and mrpt::round().

Here is the call graph for this function:

◆ drawImage() [1/2]

virtual void mrpt::img::CCanvas::drawImage ( int  x,
int  y,
const mrpt::img::CImage img,
float  rotation,
float  scale 
)
virtualinherited

Draws an image as a bitmap at a given position, with some custom scale and rotation changes.

Parameters
x0The top-left corner x coordinates on this canvas where the image is to be drawn
y0The top-left corner y coordinates on this canvas where the image is to be drawn
rotationThe rotation in radians, positive values being anti-clockwise direction, 0 is the normal position.
scaleThe scale factor, e.g. 2 means twice the original size.
imgThe image to be drawn in this canvas This method may be redefined in some classes implementing this interface in a more appropiate manner.

Reimplemented in mrpt::img::CEnhancedMetaFile.

◆ drawImage() [2/2]

void CImage::drawImage ( int  x,
int  y,
const mrpt::img::CImage img 
)
overridevirtual

Draws an image as a bitmap at a given position.

Parameters
x0The top-left corner x coordinates on this canvas where the image is to be drawn
y0The top-left corner y coordinates on this canvas where the image is to be drawn
imgThe image to be drawn in this canvas This method may be redefined in some classes implementing this interface in a more appropiate manner.

Reimplemented from mrpt::img::CCanvas.

Definition at line 1142 of file CImage.cpp.

References getHeight(), getWidth(), m_impl, and makeSureImageIsLoaded().

Referenced by mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), and mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawMark()

void CCanvas::drawMark ( int  x0,
int  y0,
const mrpt::img::TColor  color,
char  type,
int  size = 5,
unsigned int  width = 1 
)
inherited

Draw a mark.

Parameters
x0The point x coordinate
y0The point y coordinate
colorThe color of the cross
sizeThe size of the cross
typeThe cross type. It could be: 'x', '+', ':'(like '+' but clear at the center dot), or 's' (square)
widthThe desired width of the cross (this is IGNORED yet)

Definition at line 304 of file CCanvas.cpp.

References mrpt::math::size(), and THROW_EXCEPTION.

Referenced by mrpt::img::CCanvas::drawFeatures(), mrpt::img::CCanvas::drawFeaturesSimple(), and mrpt::gui::CDisplayWindow::plot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ duplicateGetSmartPtr()

mrpt::rtti::CObject::Ptr CObject::duplicateGetSmartPtr ( ) const
inlineinherited

Makes a deep copy of the object and returns a smart pointer to it.

Definition at line 204 of file CObject.h.

References mrpt::rtti::CObject::clone().

Referenced by mrpt::obs::CRawlog::insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipseGaussian()

void CCanvas::ellipseGaussian ( const mrpt::math::CMatrixFixed< double, 2, 2 > &  cov2D,
const double  mean_x,
const double  mean_y,
double  confIntervalStds = 2,
const mrpt::img::TColor color = mrpt::img::TColor(255, 255, 255),
unsigned int  width = 1,
int  nEllipsePoints = 20 
)
inherited

Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution.

Parameters
mean_xThe x coordinate of the center point of the ellipse.
mean_yThe y coordinate of the center point of the ellipse.
cov2DA 2x2 covariance matrix.
confIntervalStdsHow many "sigmas" for the confidence level (i.e. 2->95%, 3=99.97%,...)
colorThe color of the ellipse
widthThe desired width of the line (this is IGNORED in this virtual class)
nEllipsePointsThe number of points to generate to approximate the ellipse shape.
Exceptions
std::exceptionOn an invalid matrix.

Definition at line 452 of file CCanvas.cpp.

References mrpt::math::MatrixVectorBase< T, CMatrixFixed< T, ROWS, COLS > >::array(), mrpt::math::CMatrixFixed< T, ROWS, COLS >::asEigen(), mrpt::math::MatrixBase< T, CMatrixFixed< T, ROWS, COLS > >::eig(), M_2PI, MRPT_END_WITH_CLEAN_UP, MRPT_START, mrpt::round(), mrpt::math::MatrixBase< T, CMatrixFixed< T, ROWS, COLS > >::setDiagonal(), and mrpt::math::MatrixVectorBase< T, CMatrixFixed< T, ROWS, COLS > >::transpose().

Here is the call graph for this function:

◆ equalizeHist()

void CImage::equalizeHist ( CImage out_img) const

Equalize the image histogram, saving the new image in the given output object.

Note
RGB images are first converted to HSV color space, then equalized for brightness (V)

Definition at line 1902 of file CImage.cpp.

References getChannelCount(), m_impl, resize(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ extract_patch()

void CImage::extract_patch ( CImage patch,
const unsigned int  col = 0,
const unsigned int  row = 0,
const unsigned int  width = 1,
const unsigned int  height = 1 
) const

Extract a patch from this image, saveing it into "patch" (its previous contents will be overwritten).

The patch to extract starts at (col,row) and has the given dimensions.

See also
update_patch

Definition at line 1166 of file CImage.cpp.

References m_impl, and makeSureImageIsLoaded().

Referenced by mrpt::vision::CFeatureExtraction::extractFeaturesAKAZE(), mrpt::vision::CFeatureExtraction::extractFeaturesFAST(), mrpt::vision::CFeatureExtraction::extractFeaturesKLT(), mrpt::vision::CFeatureExtraction::extractFeaturesLSD(), mrpt::vision::CFeatureExtraction::extractFeaturesORB(), mrpt::vision::CFeatureExtraction::extractFeaturesSIFT(), mrpt::vision::CFeatureExtraction::extractFeaturesSURF(), and mrpt::vision::openCV_cross_correlation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filledRectangle()

void CCanvas::filledRectangle ( int  x0,
int  y0,
int  x1,
int  y1,
const mrpt::img::TColor  color 
)
virtualinherited

Draws a filled rectangle.

Parameters
x0The top-left x coordinate
y0The top-left y coordinate
x1The right-bottom x coordinate
y1The right-bottom y coordinate
colorThe color of the rectangle fill This method may be redefined in some classes implementing this interface in a more appropiate manner.
See also
rectangle

Definition at line 205 of file CCanvas.cpp.

References getHeight().

Referenced by mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), mrpt::img::CEnhancedMetaFile::CEnhancedMetaFile(), mrpt::gui::CDisplayWindow::plot(), and mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filterGaussian()

void CImage::filterGaussian ( CImage out_img,
int  W = 3,
int  H = 3,
double  sigma = 1.0 
) const

Filter the image with a Gaussian filter with a window size WxH, replacing "this" image by the filtered one.

For inplace operation, set out_img to this.

Definition at line 1727 of file CImage.cpp.

References getChannelCount(), m_impl, makeSureImageIsLoaded(), and resize().

Referenced by mrpt::maps::COccupancyGridMap2D::getAsImageFiltered().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filterMedian()

void CImage::filterMedian ( CImage out_img,
int  W = 3 
) const

Filter the image with a Median filter with a window size WxW, returning the filtered image in out_img.

For inplace operation, set out_img to this.

Definition at line 1712 of file CImage.cpp.

References getChannelCount(), m_impl, makeSureImageIsLoaded(), and resize().

Referenced by mrpt::maps::COccupancyGridMap2D::getAsImageFiltered().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flipHorizontal()

void CImage::flipHorizontal ( )

Flips the image horizontally.

See also
swapRB(), flipVertical()

Definition at line 1651 of file CImage.cpp.

References m_impl, and makeSureImageIsLoaded().

Here is the call graph for this function:

◆ flipVertical()

void CImage::flipVertical ( )

Flips the image vertically.

See also
swapRB(), flipHorizontal()

Definition at line 1643 of file CImage.cpp.

References m_impl, and makeSureImageIsLoaded().

Here is the call graph for this function:

◆ forceLoad()

void mrpt::img::CImage::forceLoad ( ) const
inline

For external storage image objects only, this method makes sure the image is loaded in memory.

Note that usually images are loaded on-the-fly on first access and there's no need to call this.

Definition at line 806 of file img/CImage.h.

References makeSureImageIsLoaded().

Referenced by copyFromForceLoad().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unsafe()

uint8_t * CImage::get_unsafe ( unsigned int  col,
unsigned int  row,
uint8_t  channel = 0 
) const

Access to pixels without checking boundaries - Use normally the () operator better, which checks the coordinates.

See also
CImage::operator()

Definition at line 476 of file CImage.cpp.

References internal_get().

Here is the call graph for this function:

◆ getAsFloat() [1/2]

float CImage::getAsFloat ( unsigned int  col,
unsigned int  row,
unsigned int  channel 
) const

Returns the contents of a given pixel at the desired channel, in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image.

Exceptions
std::exceptionOn pixel coordinates out of bounds
See also
operator()

Definition at line 893 of file CImage.cpp.

References makeSureImageIsLoaded().

Referenced by getMaxAsFloat(), and mrpt::maps::COccupancyGridMap2D::loadFromBitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsFloat() [2/2]

float CImage::getAsFloat ( unsigned int  col,
unsigned int  row 
) const

Returns the contents of a given pixel (for gray-scale images, in color images the gray scale equivalent is computed for the pixel), in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image.

Exceptions
std::exceptionOn pixel coordinates out of bounds
See also
operator()

Definition at line 901 of file CImage.cpp.

References isColor().

Here is the call graph for this function:

◆ getAsIplImage()

void CImage::getAsIplImage ( IplImage dest) const

(DEPRECATED, DO NOT USE - Kept here only to interface opencv 2.4)

Definition at line 2180 of file CImage.cpp.

References ASSERT_, m_impl, and makeSureImageIsLoaded().

Referenced by mrpt::vision::CFeatureExtraction::internal_computeLogPolarImageDescriptors(), and mrpt::vision::CFeatureExtraction::internal_computePolarImageDescriptors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsMatrix() [1/2]

void CImage::getAsMatrix ( mrpt::math::CMatrixFloat outMatrix,
bool  doResize = true,
int  x_min = 0,
int  y_min = 0,
int  x_max = -1,
int  y_max = -1,
bool  normalize_01 = true 
) const

Returns the image as a matrix with pixel grayscale values in the range [0,1].

Matrix indexes in this order: M(row,column)

Parameters
doResizeIf set to true (default), the output matrix will be always the size of the image at output. If set to false, the matrix will be enlarged to the size of the image, but it will not be cropped if it has room enough (useful for FFT2D,...)
x_minThe starting "x" coordinate to extract (default=0=the first column)
y_minThe starting "y" coordinate to extract (default=0=the first row)
x_maxThe final "x" coordinate (inclusive) to extract (default=-1=the last column)
y_maxThe final "y" coordinate (inclusive) to extract (default=-1=the last row)
normalize_01Normalize the image values such that they fall in the range [0,1] (default: true). If set to false, the matrix will hold numbers in the range [0,255].
See also
setFromMatrix

Definition at line 1238 of file CImage.cpp.

References ASSERT_, mrpt::math::MatrixVectorBase< Scalar, Derived >::coeffRef(), mrpt::math::CMatrixDynamic< T >::cols(), isColor(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, mrpt::math::CMatrixDynamic< T >::rows(), and mrpt::math::CMatrixDynamic< T >::setSize().

Referenced by cross_correlation_FFT(), and mrpt::vision::normalizeImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsMatrix() [2/2]

void CImage::getAsMatrix ( mrpt::math::CMatrix_u8 outMatrix,
bool  doResize = true,
int  x_min = 0,
int  y_min = 0,
int  x_max = -1,
int  y_max = -1 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1289 of file CImage.cpp.

References ASSERT_, mrpt::math::MatrixVectorBase< Scalar, Derived >::coeffRef(), mrpt::math::CMatrixDynamic< T >::cols(), isColor(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, mrpt::math::CMatrixDynamic< T >::rows(), and mrpt::math::CMatrixDynamic< T >::setSize().

Here is the call graph for this function:

◆ getAsMatrixTiled()

void CImage::getAsMatrixTiled ( mrpt::math::CMatrixFloat outMatrix) const

Returns the image as a matrix, where the image is "tiled" (repeated) the required number of times to fill the entire size of the matrix on input.

Definition at line 1515 of file CImage.cpp.

References mrpt::math::CMatrixDynamic< T >::cols(), isColor(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, and mrpt::math::CMatrixDynamic< T >::rows().

Here is the call graph for this function:

◆ getAsRGBMatrices() [1/2]

void CImage::getAsRGBMatrices ( mrpt::math::CMatrixFloat outMatrixR,
mrpt::math::CMatrixFloat outMatrixG,
mrpt::math::CMatrixFloat outMatrixB,
bool  doResize = true,
int  x_min = 0,
int  y_min = 0,
int  x_max = -1,
int  y_max = -1 
) const

Returns the image as RGB matrices with pixel values in the range [0,1].

Matrix indexes in this order: M(row,column)

Parameters
doResizeIf set to true (default), the output matrix will be always the size of the image at output. If set to false, the matrix will be enlarged to the size of the image, but it will not be cropped if it has room enough (useful for FFT2D,...)
x_minThe starting "x" coordinate to extract (default=0=the first column)
y_minThe starting "y" coordinate to extract (default=0=the first row)
x_maxThe final "x" coordinate (inclusive) to extract (default=-1=the last column)
y_maxThe final "y" coordinate (inclusive) to extract (default=-1=the last row)
See also
setFromRGBMatrices

Definition at line 1337 of file CImage.cpp.

References ASSERT_, mrpt::math::MatrixVectorBase< Scalar, Derived >::coeffRef(), mrpt::math::CMatrixDynamic< T >::cols(), G, isColor(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, R, mrpt::math::CMatrixDynamic< T >::rows(), mrpt::math::CMatrixDynamic< T >::setSize(), and mrpt::u8tof().

Here is the call graph for this function:

◆ getAsRGBMatrices() [2/2]

void CImage::getAsRGBMatrices ( mrpt::math::CMatrix_u8 outMatrixR,
mrpt::math::CMatrix_u8 outMatrixG,
mrpt::math::CMatrix_u8 outMatrixB,
bool  doResize = true,
int  x_min = 0,
int  y_min = 0,
int  x_max = -1,
int  y_max = -1 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1386 of file CImage.cpp.

References ASSERT_, mrpt::math::MatrixVectorBase< Scalar, Derived >::coeffRef(), mrpt::math::CMatrixDynamic< T >::cols(), G, isColor(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, R, mrpt::math::CMatrixDynamic< T >::rows(), and mrpt::math::CMatrixDynamic< T >::setSize().

Here is the call graph for this function:

◆ getChannelCount()

TImageChannels CImage::getChannelCount ( ) const

Returns the number of channels, typically 1 (GRAY) or 3 (RGB)

See also
isColor

Definition at line 878 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), and THROW_EXCEPTION.

Referenced by equalizeHist(), filterGaussian(), filterMedian(), mrpt::vision::CFeatureExtraction::internal_computeLogPolarImageDescriptors(), mrpt::vision::CFeatureExtraction::internal_computePolarImageDescriptors(), joinImagesHorz(), mrpt::gui::MRPTImage2wxImage(), mrpt::vision::normalizeImage(), mrpt::vision::CStereoRectifyMap::rectify(), rotateImage(), scaleHalf(), scaleImage(), mrpt::vision::CUndistortMap::undistort(), and undistort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getChannelsOrder()

std::string CImage::getChannelsOrder ( ) const

As of mrpt 2.0.0, this returns either "GRAY" or "BGR".

Definition at line 828 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), and THROW_EXCEPTION.

Referenced by mrpt::maps::CColouredPointsMap::colourFromObservation(), and mrpt::gui::MRPTImage2wxImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getClassName()

static constexpr auto mrpt::img::CImage::getClassName ( )
inlinestatic

Definition at line 150 of file img/CImage.h.

◆ getExternalStorageFile()

std::string mrpt::img::CImage::getExternalStorageFile ( ) const
inlinenoexcept

Only if isExternallyStored() returns true.

See also
getExternalStorageFileAbsolutePath

Definition at line 785 of file img/CImage.h.

References m_externalFile.

◆ getExternalStorageFileAbsolutePath() [1/2]

void CImage::getExternalStorageFileAbsolutePath ( std::string &  out_path) const

Only if isExternallyStored() returns true.

See also
getExternalStorageFile

Definition at line 1621 of file CImage.cpp.

References ASSERT_, IMAGES_PATH_BASE(), and m_externalFile.

Here is the call graph for this function:

◆ getExternalStorageFileAbsolutePath() [2/2]

std::string mrpt::img::CImage::getExternalStorageFileAbsolutePath ( ) const
inline

Only if isExternallyStored() returns true.

See also
getExternalStorageFile

Definition at line 794 of file img/CImage.h.

Referenced by makeSureImageIsLoaded().

Here is the caller graph for this function:

◆ getHeight()

size_t CImage::getHeight ( ) const
overridevirtual

Returns the height of the image in pixels.

See also
getSize

Implements mrpt::img::CCanvas.

Definition at line 849 of file CImage.cpp.

References m_imgIsExternalStorage, m_impl, and makeSureImageIsLoaded().

Referenced by mrpt::opengl::CMeshFast::adjustGridToImageAR(), mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), mrpt::opengl::CMeshFast::assignImage(), mrpt::opengl::CMesh::assignImage(), mrpt::opengl::CMeshFast::assignImageAndZ(), mrpt::opengl::CMesh::assignImageAndZ(), mrpt::vision::checkerBoardStereoCalibration(), mrpt::detectors::CFaceDetection::checkIfDiagonalSurface(), mrpt::detectors::CFaceDetection::checkIfDiagonalSurface2(), mrpt::detectors::CFaceDetection::checkIfFacePlaneCov(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), colorImage(), mrpt::maps::CColouredPointsMap::colourFromObservation(), mrpt::vision::computeMainOrientation(), mrpt::vision::computeSAD(), correlate(), cross_correlation_FFT(), cvFindChessboardCorners3(), mrpt::slam::CMetricMapBuilderRBPF::drawCurrentEstimationToImage(), mrpt::img::CEnhancedMetaFile::drawImage(), mrpt::img::CCanvas::drawImage(), drawImage(), expect_identical(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), mrpt::vision::CFeatureExtraction::extractFeaturesAKAZE(), mrpt::vision::CFeatureExtraction::extractFeaturesFAST(), mrpt::vision::CFeatureExtraction::extractFeaturesKLT(), mrpt::vision::CFeatureExtraction::extractFeaturesLSD(), mrpt::vision::CFeatureExtraction::extractFeaturesORB(), mrpt::vision::CFeatureExtraction::extractFeaturesSIFT(), mrpt::vision::CFeatureExtraction::extractFeaturesSURF(), fillImagePseudoRandom(), find_chessboard_corners_multiple(), getMaxAsFloat(), mrpt::hwdrivers::CCameraSensor::getNextFrame(), icvGenerateQuads(), mrpt::vision::CFeatureExtraction::internal_computeSpinImageDescriptors(), mrpt::maps::detail::pointmap_traits< CColouredPointsMap >::internal_loadFromRangeScan3D_init(), mrpt::vision::CGenericFeatureTracker::internal_trackFeatures(), joinImagesHorz(), mrpt::maps::COccupancyGridMap2D::loadFromBitmap(), main(), mrpt::vision::matchFeatures(), mrpt::gui::MRPTImage2wxImage(), mrpt::vision::normalizeImage(), mrpt::vision::openCV_cross_correlation(), mrpt::vision::CVideoFileWriter::operator<<(), rotateImage(), mrpt::apps::CGridMapAlignerApp::run(), mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences(), mrpt::maps::COccupancyGridMap2D::saveAsEMFTwoMapsWithCorrespondences(), scaleImage(), mrpt::gui::CDisplayWindow::showTiledImageAndPoints(), mrpt::ros1bridge::toROS(), mrpt::vision::CFeatureTracker_KL::trackFeatures_impl_templ(), mrpt::vision::CUndistortMap::undistort(), and mrpt::vision::CVideoFileWriter::writeImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getImagesPathBase()

const std::string & CImage::getImagesPathBase ( )
static

By default, ".".

See also
setExternalStorage

Definition at line 76 of file CImage.cpp.

References IMAGES_PATH_BASE().

Referenced by mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::initClass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMaxAsFloat()

float CImage::getMaxAsFloat ( ) const

Return the maximum pixel value of the image, as a float value in the range [0,1].

See also
getAsFloat

Definition at line 921 of file CImage.cpp.

References getAsFloat(), getHeight(), and getWidth().

Here is the call graph for this function:

◆ getPixelDepth()

PixelDepth CImage::getPixelDepth ( ) const

Definition at line 294 of file CImage.cpp.

References cvDepth2PixelDepth(), m_impl, MRPT_END, MRPT_START, and THROW_EXCEPTION.

Referenced by mrpt::img::CCanvas::drawImage(), and setPixel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRowStride()

size_t CImage::getRowStride ( ) const

Returns the row stride of the image: this is the number of bytes between two consecutive rows.

You can access the pointer to the first row with ptrLine(0)

See also
getSize, as, ptr, ptrLine

Definition at line 839 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), and THROW_EXCEPTION.

Referenced by mrpt::gui::MRPTImage2wxImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRuntimeClass()

virtual const mrpt::rtti::TRuntimeClassId* mrpt::img::CImage::GetRuntimeClass ( ) const
overridevirtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::serialization::CSerializable.

◆ GetRuntimeClassIdStatic()

static const mrpt::rtti::TRuntimeClassId& mrpt::img::CImage::GetRuntimeClassIdStatic ( )
static

◆ getSize() [1/2]

void CImage::getSize ( TImageSize s) const

Return the size of the image.

See also
getWidth, getHeight

Definition at line 807 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), THROW_EXCEPTION, mrpt::img::TPixelCoord::x, and mrpt::img::TPixelCoord::y.

Referenced by mrpt::vision::checkerBoardStereoCalibration(), mrpt::vision::computeSAD(), and mrpt::detectors::CFaceDetection::experimental_calcHist().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSize() [2/2]

TImageSize mrpt::img::CImage::getSize ( ) const
inline

Return the size of the image.

See also
getWidth, getHeight

Definition at line 646 of file img/CImage.h.

Referenced by scaleDouble().

Here is the caller graph for this function:

◆ getWidth()

size_t CImage::getWidth ( ) const
overridevirtual

Returns the width of the image in pixels.

See also
getSize

Implements mrpt::img::CCanvas.

Definition at line 818 of file CImage.cpp.

References m_imgIsExternalStorage, m_impl, and makeSureImageIsLoaded().

Referenced by mrpt::opengl::CMeshFast::adjustGridToImageAR(), mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), mrpt::opengl::CMeshFast::assignImage(), mrpt::opengl::CMesh::assignImage(), mrpt::opengl::CMeshFast::assignImageAndZ(), mrpt::opengl::CMesh::assignImageAndZ(), mrpt::vision::checkerBoardStereoCalibration(), mrpt::detectors::CFaceDetection::checkIfDiagonalSurface(), mrpt::detectors::CFaceDetection::checkIfDiagonalSurface2(), mrpt::detectors::CFaceDetection::checkIfFacePlaneCov(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), colorImage(), mrpt::maps::CColouredPointsMap::colourFromObservation(), mrpt::vision::computeMainOrientation(), mrpt::vision::computeSAD(), correlate(), cross_correlation_FFT(), cvFindChessboardCorners3(), mrpt::img::CEnhancedMetaFile::drawImage(), mrpt::img::CCanvas::drawImage(), drawImage(), expect_identical(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), mrpt::vision::CFeatureExtraction::extractFeaturesAKAZE(), mrpt::vision::CFeatureExtraction::extractFeaturesFAST(), mrpt::vision::CFeatureExtraction::extractFeaturesKLT(), mrpt::vision::CFeatureExtraction::extractFeaturesLSD(), mrpt::vision::CFeatureExtraction::extractFeaturesORB(), mrpt::vision::CFeatureExtraction::extractFeaturesSIFT(), mrpt::vision::CFeatureExtraction::extractFeaturesSURF(), fillImagePseudoRandom(), find_chessboard_corners_multiple(), getMaxAsFloat(), mrpt::hwdrivers::CCameraSensor::getNextFrame(), icvGenerateQuads(), mrpt::vision::CFeatureExtraction::internal_computeSpinImageDescriptors(), mrpt::maps::detail::pointmap_traits< CColouredPointsMap >::internal_loadFromRangeScan3D_init(), mrpt::vision::CGenericFeatureTracker::internal_trackFeatures(), mrpt::maps::COccupancyGridMap2D::loadFromBitmap(), main(), mrpt::vision::matchFeatures(), mrpt::gui::MRPTImage2wxImage(), mrpt::vision::normalizeImage(), mrpt::vision::openCV_cross_correlation(), mrpt::vision::CVideoFileWriter::operator<<(), rotateImage(), mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences(), mrpt::maps::COccupancyGridMap2D::saveAsEMFTwoMapsWithCorrespondences(), scaleImage(), mrpt::gui::CDisplayWindow::showImagesAndMatchedPoints(), mrpt::gui::CDisplayWindow::showTiledImageAndPoints(), mrpt::ros1bridge::toROS(), mrpt::vision::CFeatureTracker_KL::trackFeatures_impl_templ(), mrpt::vision::CUndistortMap::undistort(), and mrpt::vision::CVideoFileWriter::writeImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grayscale() [1/2]

CImage CImage::grayscale ( ) const

Returns a grayscale version of the image, or a shallow copy of itself if it is already a grayscale image.

Definition at line 933 of file CImage.cpp.

Referenced by buildPyramid_templ(), CImage(), mrpt::vision::openCV_cross_correlation(), and TEST().

Here is the caller graph for this function:

◆ grayscale() [2/2]

bool CImage::grayscale ( CImage ret) const

Definition at line 965 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), my_img_to_grayscale(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ internal_fromIPL()

void CImage::internal_fromIPL ( const IplImage iplImage,
copy_type_t  c 
)
protected

Definition at line 351 of file CImage.cpp.

References ASSERT_, clear(), mrpt::img::DEEP_COPY, m_impl, MRPT_END, MRPT_START, and THROW_EXCEPTION.

Referenced by loadFromIplImage(), and setFromIplImageReadOnly().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ internal_get()

uint8_t * CImage::internal_get ( int  col,
int  row,
uint8_t  channel = 0 
) const
protected

Definition at line 464 of file CImage.cpp.

References m_impl, and makeSureImageIsLoaded().

Referenced by at(), get_unsafe(), ptr(), and ptrLine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isColor()

bool CImage::isColor ( ) const

Returns true if the image is RGB, false if it is grayscale.

Definition at line 859 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), and THROW_EXCEPTION.

Referenced by buildPyramid_templ(), CImage(), colorImage(), mrpt::maps::CColouredPointsMap::colourFromObservation(), mrpt::img::CCanvas::drawImage(), getAsFloat(), getAsMatrix(), getAsMatrixTiled(), getAsRGBMatrices(), mrpt::vision::CFeatureExtraction::internal_computeSpinImageDescriptors(), mrpt::maps::detail::pointmap_traits< CColouredPointsMap >::internal_loadFromRangeScan3D_init(), loadFromFile(), loadFromStreamAsJPEG(), mrpt::gui::MRPTImage2wxImage(), mrpt::vision::openCV_cross_correlation(), serializeTo(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty()

bool CImage::isEmpty ( ) const

Returns true if the object is in the state after default constructor.

Definition at line 869 of file CImage.cpp.

References m_imgIsExternalStorage, m_impl, and THROW_EXCEPTION.

◆ isExternallyStored()

bool mrpt::img::CImage::isExternallyStored ( ) const
inlinenoexcept

See setExternalStorage().

Definition at line 782 of file img/CImage.h.

References m_imgIsExternalStorage.

Referenced by mrpt::vision::checkerBoardStereoCalibration().

Here is the caller graph for this function:

◆ isOriginTopLeft()

bool CImage::isOriginTopLeft ( ) const

Returns true (as of MRPT v2.0.0, it's fixed)

Definition at line 888 of file CImage.cpp.

Referenced by mrpt::img::CCanvas::textOut().

Here is the caller graph for this function:

◆ joinImagesHorz()

void CImage::joinImagesHorz ( const CImage im1,
const CImage im2 
)

Joins two images side-by-side horizontally.

Both images must have the same number of rows and be of the same type (i.e. depth and color mode)

Parameters
im1[IN] The first image.
im2[IN] The other image.

Definition at line 1887 of file CImage.cpp.

References ASSERT_, getChannelCount(), getHeight(), m_impl, and resize().

Referenced by mrpt::gui::CDisplayWindow::showImagesAndMatchedPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ KLT_response()

float MRPT_DISABLE_FULL_OPTIMIZATION CImage::KLT_response ( const unsigned int  x,
const unsigned int  y,
const unsigned int  half_window_size 
) const

Compute the KLT response at a given pixel (x,y) - Only for grayscale images (for efficiency it avoids converting to grayscale internally).

See KLT_response() for more details on the internal optimizations of this method, but this graph shows a general view:

Definition at line 1961 of file CImage.cpp.

References ASSERTMSG_, and m_impl.

Referenced by mrpt::vision::CFeatureExtraction::extractFeaturesFAST(), mrpt::vision::CGenericFeatureTracker::internal_trackFeatures(), and mrpt::vision::detail::trackFeatures_checkResponses_impl_simple().

Here is the caller graph for this function:

◆ line()

void CImage::line ( int  x0,
int  y0,
int  x1,
int  y1,
const mrpt::img::TColor  color,
unsigned int  width = 1,
TPenStyle  penStyle = psSolid 
)
overridevirtual

Draws a line.

Parameters
x0The starting point x coordinate
y0The starting point y coordinate
x1The end point x coordinate
y1The end point y coordinate
colorThe color of the line
widthThe desired width of the line (this is IGNORED in this virtual class) This method may be redefined in some classes implementing this interface in a more appropiate manner.

Reimplemented from mrpt::img::CCanvas.

Definition at line 1117 of file CImage.cpp.

References mrpt::img::TColor::B, mrpt::img::TColor::G, m_impl, makeSureImageIsLoaded(), and mrpt::img::TColor::R.

Referenced by main(), mrpt::gui::CDisplayWindow::plot(), mrpt::apps::CGridMapAlignerApp::run(), mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences(), and mrpt::gui::CDisplayWindow::showTiledImageAndPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromFile()

bool CImage::loadFromFile ( const std::string &  fileName,
int  isColor = -1 
)

Load image from a file, whose format is determined from the extension (internally uses OpenCV).

Parameters
fileNameThe file to read from.
isColorSpecifies colorness of the loaded image:
  • if >0, the loaded image is forced to be color 3-channel image;
  • if 0, the loaded image is forced to be grayscale;
  • if <0, the loaded image will be loaded as is (with number of channels depends on the file). The supported formats are:
  • Windows bitmaps - BMP, DIB;
  • JPEG files - JPEG, JPG, JPE;
  • Portable Network Graphics - PNG;
  • Portable image format - PBM, PGM, PPM;
  • Sun rasters - SR, RAS;
  • TIFF files - TIFF, TIF.
Returns
False on any error
See also
saveToFile, setExternalStorage,loadFromXPM, loadTGA

Definition at line 305 of file CImage.cpp.

References isColor(), m_imgIsExternalStorage, m_impl, MRPT_END, MRPT_START, MRPT_TODO(), and THROW_EXCEPTION.

Referenced by makeSureImageIsLoaded(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromIplImage()

void mrpt::img::CImage::loadFromIplImage ( const IplImage iplImage,
copy_type_t  c = DEEP_COPY 
)
inline

Assigns from an image in IplImage format.

Definition at line 513 of file img/CImage.h.

References internal_fromIPL().

Here is the call graph for this function:

◆ loadFromMemoryBuffer() [1/2]

void CImage::loadFromMemoryBuffer ( unsigned int  width,
unsigned int  height,
bool  color,
unsigned char *  rawpixels,
bool  swapRedBlue = false 
)

Reads the image from raw pixels buffer in memory.

Definition at line 365 of file CImage.cpp.

References mrpt::img::CH_GRAY, mrpt::img::CH_RGB, m_imgIsExternalStorage, m_impl, mrpt::system::os::memcpy(), MRPT_END, MRPT_START, resize(), and THROW_EXCEPTION.

Referenced by mrpt::hwdrivers::CImageGrabber_dc1394::getObservation(), mrpt::hwdrivers::CImageGrabber_FlyCapture2::getObservation(), mrpt::hwdrivers::CDUO3DCamera::getObservations(), and mrpt::hwdrivers::CFFMPEG_InputStream::retrieveFrame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromMemoryBuffer() [2/2]

void CImage::loadFromMemoryBuffer ( unsigned int  width,
unsigned int  height,
unsigned int  bytesPerRow,
unsigned char *  red,
unsigned char *  green,
unsigned char *  blue 
)

Reads a color image from three raw pixels buffers in memory.

bytesPerRow is the number of bytes per row per channel, i.e. the row increment.

Definition at line 1044 of file CImage.cpp.

References mrpt::img::CH_RGB, mrpt::img::D8U, m_impl, MRPT_END, MRPT_START, and resize().

Here is the call graph for this function:

◆ loadFromStreamAsJPEG()

void CImage::loadFromStreamAsJPEG ( mrpt::io::CStream in)

Reads the image from a binary stream containing a binary jpeg file.

Exceptions
std::exceptionOn pixel coordinates out of bounds

Definition at line 452 of file CImage_JPEG_streams.cpp.

References mrpt::img::CH_GRAY, mrpt::img::CH_RGB, isColor(), jpeg_create_decompress, jpeg_stdio_src(), JPOOL_IMAGE, m_impl, mrpt::system::os::memcpy(), MRPT_END, MRPT_START, MRPT_TODO(), jpeg_decompress_struct::out_color_components, jpeg_decompress_struct::output_components, jpeg_decompress_struct::output_height, jpeg_decompress_struct::output_width, and resize().

Referenced by mrpt::hwdrivers::CRovio::captureImageAsync(), and serializeFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromXPM()

bool mrpt::img::CImage::loadFromXPM ( const char *const *  xpm_array,
bool  swap_rb = true 
)

Loads the image from an XPM array, as #include'd from a ".xpm" file.

Parameters
[in]swap_rbSwaps red/blue channels from loaded image. Seems to be always needed, so it's enabled by default.
See also
loadFromFile
Returns
false on any error
See also
loadFromFile
Returns
false on any error

Definition at line 484 of file CImage_loadXPM.cpp.

References ASSERTMSG_, XPMColorMapData::B, mrpt::img::CH_RGB, mrpt::opengl::internal::data, mrpt::containers::end(), XPMColorMapData::G, GetRGBFromName(), ParseColor(), XPMColorMapData::R, resize(), swapRB(), THROW_EXCEPTION, and THROW_EXCEPTION_FMT.

Here is the call graph for this function:

◆ loadTGA()

bool CImage::loadTGA ( const std::string &  fileName,
mrpt::img::CImage out_RGB,
mrpt::img::CImage out_alpha 
)
static

Loads a TGA true-color RGBA image as two CImage objects, one for the RGB channels plus a separate gray-level image with A channel.

Returns
true on success

Definition at line 2097 of file CImage.cpp.

References mrpt::img::CH_GRAY, mrpt::img::CH_RGB, mrpt::opengl::internal::data, mrpt::containers::end(), m_impl, and resize().

Here is the call graph for this function:

◆ makeDeepCopy()

CImage CImage::makeDeepCopy ( ) const

Returns a deep copy of this image.

If the image is externally-stored, there is no difference with a shallow copy.

See also
makeShallowCopy()

Definition at line 206 of file CImage.cpp.

References m_impl, and THROW_EXCEPTION.

Referenced by mrpt::gui::MRPTImage2wxImage(), and TEST().

Here is the caller graph for this function:

◆ makeShallowCopy()

CImage mrpt::img::CImage::makeShallowCopy ( ) const
inline

Returns a shallow copy of the original image.

Definition at line 484 of file img/CImage.h.

Referenced by mrpt::detectors::CObjectDetection::detectObjects(), mrpt::vision::openCV_cross_correlation(), and setFromImageReadOnly().

Here is the caller graph for this function:

◆ makeSureImageIsLoaded()

void CImage::makeSureImageIsLoaded ( ) const
protected

Checks if the image is of type "external storage", and if so and not loaded yet, load it.

Exceptions
CExceptionExternalImageNotFound

Definition at line 1585 of file CImage.cpp.

References getExternalStorageFileAbsolutePath(), loadFromFile(), m_externalFile, m_imgIsExternalStorage, m_impl, THROW_EXCEPTION, and THROW_TYPED_EXCEPTION_FMT.

Referenced by asCvMatRef(), correlate(), cross_correlation_FFT(), drawCircle(), drawImage(), extract_patch(), filterGaussian(), filterMedian(), flipHorizontal(), flipVertical(), forceLoad(), getAsFloat(), getAsIplImage(), getAsMatrix(), getAsMatrixTiled(), getAsRGBMatrices(), getChannelCount(), getChannelsOrder(), getHeight(), getRowStride(), getSize(), getWidth(), grayscale(), internal_get(), isColor(), line(), normalize(), operator()(), rectifyImageInPlace(), rotateImage(), saveToFile(), saveToStreamAsJPEG(), scaleHalf(), scaleImage(), setFromRGBMatrices(), setPixel(), swapRB(), undistort(), and update_patch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize()

void CImage::normalize ( )

Optimize the brightness range of an image without using histogram Only for one channel images.

See also
equalizeHist

Definition at line 1230 of file CImage.cpp.

References m_impl, makeSureImageIsLoaded(), and mrpt::math::normalize().

Here is the call graph for this function:

◆ operator()()

unsigned char * CImage::operator() ( unsigned int  col,
unsigned int  row,
unsigned int  channel = 0 
) const

Returns a pointer to a given pixel information.

The coordinate origin is pixel(0,0)=top-left corner of the image.

Exceptions
std::exceptionOn pixel coordinates out of bounds

Definition at line 426 of file CImage.cpp.

References ASSERT_, mrpt::format(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, and THROW_EXCEPTION.

Here is the call graph for this function:

◆ ptr() [1/2]

template<typename T >
const T* mrpt::img::CImage::ptr ( unsigned int  col,
unsigned int  row,
unsigned int  channel = 0 
) const
inline

Returns a pointer to a given pixel, without checking for boundaries.

See also
The CImage::operator() which does check for coordinate limits.

Definition at line 583 of file img/CImage.h.

References internal_get().

Referenced by mrpt::vision::CFeatureExtraction::internal_computeSpinImageDescriptors(), and mrpt::maps::detail::pointmap_traits< CColouredPointsMap >::internal_loadFromRangeScan3D_prepareOneRange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ptr() [2/2]

template<typename T >
T* mrpt::img::CImage::ptr ( unsigned int  col,
unsigned int  row,
unsigned int  channel = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 590 of file img/CImage.h.

References internal_get().

Here is the call graph for this function:

◆ ptrLine() [1/2]

template<typename T >
const T* mrpt::img::CImage::ptrLine ( unsigned int  row) const
inline

Returns a pointer to the first pixel of the given line.

See also
ptr, at

Definition at line 597 of file img/CImage.h.

References internal_get().

Referenced by mrpt::gui::MRPTImage2wxImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ptrLine() [2/2]

template<typename T >
T* mrpt::img::CImage::ptrLine ( unsigned int  row)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 603 of file img/CImage.h.

References internal_get().

Here is the call graph for this function:

◆ rectangle()

void CCanvas::rectangle ( int  x0,
int  y0,
int  x1,
int  y1,
const mrpt::img::TColor  color,
unsigned int  width = 1 
)
inherited

Draws a rectangle (an empty rectangle, without filling)

Parameters
x0The top-left x coordinate
y0The top-left y coordinate
x1The right-bottom x coordinate
y1The right-bottom y coordinate
colorThe color of the line
widthThe desired width of the line.
See also
filledRectangle

Definition at line 161 of file CCanvas.cpp.

Referenced by mrpt::vision::addFeaturesToImage(), and mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences().

Here is the caller graph for this function:

◆ rectifyImageInPlace()

void CImage::rectifyImageInPlace ( void *  mapX,
void *  mapY 
)

Rectify an image (undistorts and rectification) from a stereo pair according to a pair of precomputed rectification maps.

Parameters
mapX,mapY[IN] The pre-computed maps of the rectification (should be computed beforehand)
See also
mrpt::vision::CStereoRectifyMap, mrpt::vision::computeStereoRectificationMaps

Definition at line 1667 of file CImage.cpp.

References clear(), m_impl, and makeSureImageIsLoaded().

Here is the call graph for this function:

◆ resize()

void CImage::resize ( std::size_t  width,
std::size_t  height,
TImageChannels  nChannels,
PixelDepth  depth = PixelDepth::D8U 
)

Changes the size of the image, erasing previous contents (does NOT scale its current content, for that, see scaleImage).

  • nChannels: Can be 3 for RGB images or 1 for grayscale images.
    See also
    scaleImage

Definition at line 247 of file CImage.cpp.

References mrpt::img::D8U, mrpt::format(), m_impl, MRPT_END, MRPT_START, pixelDepth2IPLCvDepth(), and THROW_EXCEPTION.

Referenced by CImage(), colorImage(), mrpt::slam::CMetricMapBuilderRBPF::drawCurrentEstimationToImage(), equalizeHist(), filterGaussian(), filterMedian(), mrpt::maps::CReflectivityGridMap2D::getAsImage(), mrpt::maps::COccupancyGridMap2D::getAsImage(), mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), joinImagesHorz(), loadFromMemoryBuffer(), loadFromStreamAsJPEG(), loadFromXPM(), loadTGA(), mrpt::vision::normalizeImage(), mrpt::vision::CStereoRectifyMap::rectify(), rotateImage(), scaleImage(), serializeFrom(), setFromMatrix(), setFromRGBMatrices(), mrpt::vision::CUndistortMap::undistort(), and undistort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotateImage()

void CImage::rotateImage ( CImage out_img,
double  ang,
unsigned int  cx,
unsigned int  cy,
double  scale = 1.0 
) const

Rotates the image by the given angle around the given center point, with an optional scale factor.

See also
resize, scaleImage

Definition at line 1767 of file CImage.cpp.

References getChannelCount(), getHeight(), getWidth(), m_impl, makeSureImageIsLoaded(), and resize().

Here is the call graph for this function:

◆ saveToFile()

bool CImage::saveToFile ( const std::string &  fileName,
int  jpeg_quality = 95 
) const

Save the image to a file, whose format is determined from the extension (internally uses OpenCV).

Parameters
fileNameThe file to write to.

The supported formats are:

  • Windows bitmaps - BMP, DIB;
  • JPEG files - JPEG, JPG, JPE;
  • Portable Network Graphics - PNG;
  • Portable image format - PBM, PGM, PPM;
  • Sun rasters - SR, RAS;
  • TIFF files - TIFF, TIF.
Parameters
jpeg_qualityOnly for JPEG files, the quality of the compression in the range [0-100]. Larger is better quality but slower.
Note
jpeg_quality is only effective if MRPT is compiled against OpenCV 1.1.0 or newer.
Returns
False on any error
See also
loadFromFile

Definition at line 330 of file CImage.cpp.

References ASSERT_, m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, params, and THROW_EXCEPTION.

Referenced by mrpt::slam::CGridMapAligner::AlignPDF_correlation(), mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), kfslam_traits< CRangeBearingKFSLAM >::doPartitioningExperiment(), mrpt::hmtslam::CHMTSLAM::generateLogFiles(), mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), mrpt::apps::CGridMapAlignerApp::run(), mrpt::apps::RBPF_SLAM_App_Base::run(), mrpt::maps::COccupancyGridMap2D::saveAsBitmapTwoMapsWithCorrespondences(), mrpt::slam::CMetricMapBuilderRBPF::saveCurrentEstimationToImage(), and mrpt::maps::CRandomFieldGridMap2D::saveMetricMapRepresentationToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToStreamAsJPEG()

void CImage::saveToStreamAsJPEG ( mrpt::io::CStream out,
const int  jpeg_quality = 95 
) const

Save image to binary stream as a JPEG (.jpg) compressed format.

Exceptions
std::exceptionOn number of rows or cols equal to zero or other errors.
See also
saveToJPEG

Definition at line 346 of file CImage_JPEG_streams.cpp.

References ASSERT_, jpeg_compress_struct::image_height, jpeg_compress_struct::image_width, jpeg_compress_struct::in_color_space, jpeg_compress_struct::input_components, JCS_GRAYSCALE, JCS_RGB, jpeg_create_compress, jpeg_stdio_dest(), m_impl, makeSureImageIsLoaded(), MRPT_END, MRPT_START, MRPT_TODO(), out, and THROW_EXCEPTION.

Referenced by serializeTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaleDouble() [1/2]

CImage mrpt::img::CImage::scaleDouble ( TInterpolationMethod  interp) const
inline

Returns a new image scaled up to double its original size.

Exceptions
std::exceptionOn odd size
See also
scaleHalf, scaleImage

Definition at line 329 of file img/CImage.h.

Referenced by TEST().

Here is the caller graph for this function:

◆ scaleDouble() [2/2]

void CImage::scaleDouble ( CImage out_image,
TInterpolationMethod  interp 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1037 of file CImage.cpp.

References getSize(), out, scaleImage(), mrpt::img::TPixelCoord::x, and mrpt::img::TPixelCoord::y.

Here is the call graph for this function:

◆ scaleHalf() [1/2]

CImage mrpt::img::CImage::scaleHalf ( TInterpolationMethod  interp) const
inline

Returns a new image scaled down to half its original size.

Exceptions
std::exceptionOn odd size
See also
scaleDouble, scaleImage, scaleHalfSmooth

Definition at line 314 of file img/CImage.h.

Referenced by TEST().

Here is the caller graph for this function:

◆ scaleHalf() [2/2]

bool CImage::scaleHalf ( CImage out_image,
TInterpolationMethod  interp 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns
true if an optimized SSE2/SSE3 version could be used.

Definition at line 989 of file CImage.cpp.

References getChannelCount(), image_SSE2_scale_half_1c8u(), image_SSE2_scale_half_smooth_1c8u(), image_SSSE3_scale_half_3c8u(), mrpt::img::IMG_INTERP_LINEAR, mrpt::img::IMG_INTERP_NN, interpolationMethod2Cv(), m_impl, makeSureImageIsLoaded(), out, resize(), mrpt::cpu::SSE2, mrpt::cpu::SSSE3, mrpt::cpu::supports(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ scaleImage()

void CImage::scaleImage ( CImage out_img,
unsigned int  width,
unsigned int  height,
TInterpolationMethod  interp = IMG_INTERP_CUBIC 
) const

Scales this image to a new size, interpolating as needed, saving the new image in a different output object, or operating in-place if out_img==this.

See also
resize, rotateImage

Definition at line 1741 of file CImage.cpp.

References getChannelCount(), getHeight(), getWidth(), interpolationMethod2Cv(), m_impl, makeSureImageIsLoaded(), resize(), and resize().

Referenced by mrpt::hwdrivers::CCameraSensor::getNextFrame(), scaleDouble(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectTextFont()

void CCanvas::selectTextFont ( const std::string &  fontName)
virtualinherited

Select the current font used when drawing text.

Parameters
fontNameThe name of the font

Valid font names:

  • 5x7
  • 6x13
  • 6x13B
  • 6x13O
  • 9x15 (Default at start-up)
  • 9x15B
  • 10x20
  • 18x18ja (Asian characters for UTF-8 strings - Only available if MRPT is built with MRPT_HAS_ASIAN_FONTS = true)

See also
textOut, The example in this page.

Definition at line 220 of file CCanvas.cpp.

References FontData::data, init_fonts_list(), list_registered_fonts, FontData::prepared_to_big_endian, and mrpt::reverseBytesInPlace().

Referenced by drawChessboardCorners(), and mrpt::img::CEnhancedMetaFile::selectVectorTextFont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SERIALIZATION_JPEG_QUALITY() [1/2]

void CImage::SERIALIZATION_JPEG_QUALITY ( int  q)
static

Unless DISABLE_JPEG_COMPRESSION=true, this sets the JPEG quality (range 1-100) of serialized RGB images.

(Default = 95)

Definition at line 61 of file CImage.cpp.

References SERIALIZATION_JPEG_QUALITY_value.

◆ SERIALIZATION_JPEG_QUALITY() [2/2]

int CImage::SERIALIZATION_JPEG_QUALITY ( )
static

Definition at line 65 of file CImage.cpp.

References SERIALIZATION_JPEG_QUALITY_value.

Referenced by serializeTo().

Here is the caller graph for this function:

◆ serializeFrom() [1/2]

virtual void mrpt::serialization::CSerializable::serializeFrom ( CSchemeArchiveBase in)
inlineprotectedvirtualinherited

Virtual method for reading (deserializing) from an abstract schema based archive.

Definition at line 74 of file CSerializable.h.

References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ serializeFrom() [2/2]

void CImage::serializeFrom ( mrpt::serialization::CArchive in,
uint8_t  serial_version 
)
overrideprotectedvirtual

Pure virtual method for reading (deserializing) from an abstract archive.

Users don't call this method directly. Instead, use stream >> object;.

Parameters
inThe input binary stream where the object data must read from.
versionThe version of the object stored in the stream: use this version number in your code to know how to read the incoming data.
Exceptions
std::exceptionOn any I/O error

Implements mrpt::serialization::CSerializable.

Definition at line 585 of file CImage.cpp.

References ASSERT_EQUAL_, mrpt::io::CMemoryStream::assignMemoryNotOwn(), mrpt::img::CH_GRAY, mrpt::img::CH_RGB, clear(), mrpt::img::D8U, loadFromStreamAsJPEG(), m_externalFile, m_imgIsExternalStorage, m_impl, MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, mrpt::serialization::CArchive::ReadBuffer(), resize(), mrpt::io::CMemoryStream::Seek(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ serializeGetVersion()

uint8_t CImage::serializeGetVersion ( ) const
overrideprotectedvirtual

Must return the current versioning number of the object.

Start in zero for new classes, and increments each time there is a change in the stored format.

Implements mrpt::serialization::CSerializable.

Definition at line 482 of file CImage.cpp.

◆ serializeTo() [1/2]

virtual void mrpt::serialization::CSerializable::serializeTo ( CSchemeArchiveBase out) const
inlineprotectedvirtualinherited

Virtual method for writing (serializing) to an abstract schema based archive.

Definition at line 64 of file CSerializable.h.

References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ serializeTo() [2/2]

void CImage::serializeTo ( mrpt::serialization::CArchive out) const
overrideprotectedvirtual

Pure virtual method for writing (serializing) to an abstract archive.

Users don't call this method directly. Instead, use stream << object;.

Exceptions
std::exceptionOn any I/O error

Implements mrpt::serialization::CSerializable.

Definition at line 490 of file CImage.cpp.

References ASSERT_, cvDepth2PixelDepth(), DISABLE_JPEG_COMPRESSION(), mrpt::io::CMemoryStream::getRawBufferData(), mrpt::io::CMemoryStream::getTotalBytesCount(), isColor(), m_externalFile, m_imgIsExternalStorage, m_impl, out, saveToStreamAsJPEG(), and SERIALIZATION_JPEG_QUALITY().

Here is the call graph for this function:

◆ setExternalStorage()

void CImage::setExternalStorage ( const std::string &  fileName)
noexcept

By using this method the image is marked as referenced to an external file, which will be loaded only under demand.

A CImage with external storage does not consume memory until some method trying to access the image is invoked (e.g. getWidth(), isColor(),...) At any moment, the image can be unloaded from memory again by invoking unload. An image becomes of type "external storage" only through calling setExternalStorage. This property remains after serializing the object. File names can be absolute, or relative to the CImage::getImagesPathBase() directory. Filenames staring with "X:\" or "/" are considered absolute paths. By calling this method the current contents of the image are NOT saved to that file, because this method can be also called to let the object know where to load the image in case its contents are required. Thus, for saving images in this format (not when loading) the proper order of commands should be:

img.saveToFile( fileName );
img.setExternalStorage( fileName );
Note
Modifications to the memory copy of the image are not automatically saved to disk.
See also
unload, isExternallyStored

Definition at line 1571 of file CImage.cpp.

References mrpt::containers::clear().

Referenced by mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFromImageReadOnly()

void mrpt::img::CImage::setFromImageReadOnly ( const CImage o)
inline

Definition at line 478 of file img/CImage.h.

References makeShallowCopy().

Here is the call graph for this function:

◆ setFromIplImageReadOnly()

void mrpt::img::CImage::setFromIplImageReadOnly ( IplImage iplImage)
inline

Definition at line 522 of file img/CImage.h.

References internal_fromIPL(), and mrpt::img::SHALLOW_COPY.

Here is the call graph for this function:

◆ setFromMatrix()

template<typename MAT >
void mrpt::img::CImage::setFromMatrix ( const MAT &  m,
bool  matrix_is_normalized = true 
)
inline

Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,1] (normalized=true) or [0,255] (normalized=false) Matrix indexes are assumed to be in this order: M(row,column)

See also
getAsMatrix

Definition at line 844 of file img/CImage.h.

References mrpt::img::CH_GRAY, MRPT_END, MRPT_START, and resize().

Referenced by mrpt::slam::CGridMapAligner::AlignPDF_correlation(), kfslam_traits< CRangeBearingKFSLAM >::doPartitioningExperiment(), mrpt::detectors::CFaceDetection::experimental_segmentFace(), mrpt::maps::CRandomFieldGridMap2D::getAsBitmapFile(), mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), mrpt::hwdrivers::COpenNI2_RGBD360::getNextObservation(), mrpt::vision::normalizeImage(), mrpt::maps::CRandomFieldGridMap2D::saveMetricMapRepresentationToFile(), and mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::updateRangeImageViewport().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFromRGBMatrices()

template<typename MAT >
void mrpt::img::CImage::setFromRGBMatrices ( const MAT &  r,
const MAT &  g,
const MAT &  b,
bool  matrix_is_normalized = true 
)
inline

Set the image from RGB matrices, given the pixels in the range [0,1] (normalized=true) or [0,255] (normalized=false) Matrix indexes are assumed to be in this order: M(row,column)

See also
getAsRGBMatrices

Definition at line 877 of file img/CImage.h.

References ASSERT_, mrpt::img::CH_RGB, makeSureImageIsLoaded(), MRPT_END, MRPT_START, and resize().

Here is the call graph for this function:

◆ setImagesPathBase()

void CImage::setImagesPathBase ( const std::string &  path)
static

Definition at line 77 of file CImage.cpp.

References IMAGES_PATH_BASE().

Referenced by mrpt::apps::RBPF_SLAM_App_Rawlog::impl_initialize(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::initClass(), mrpt::gui::CPanelCameraSelection::writeConfigFromVideoSourcePanel(), and mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::~CGraphSlamEngine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPixel()

void CImage::setPixel ( int  x,
int  y,
size_t  color 
)
overridevirtual

Changes the value of the pixel (x,y).

Pixel coordinates starts at the left-top corner of the image, and start in (0,0). The meaning of the parameter "color" depends on the implementation: it will usually be a 24bit RGB value (0x00RRGGBB), but it can also be just a 8bit gray level. This method must support (x,y) values OUT of the actual image size without neither raising exceptions, nor leading to memory access errors.

See also
at, ptr

Implements mrpt::img::CCanvas.

Definition at line 1076 of file CImage.cpp.

References ASSERT_, mrpt::img::D8U, getPixelDepth(), m_impl, makeSureImageIsLoaded(), MRPT_END, and MRPT_START.

Referenced by mrpt::detectors::CFaceDetection::experimental_segmentFace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap()

void CImage::swap ( CImage o)

Efficiently swap of two images.

Definition at line 171 of file CImage.cpp.

References m_externalFile, m_imgIsExternalStorage, and m_impl.

Referenced by mrpt::vision::CFeatureExtraction::extractFeaturesSIFT(), and TEST().

Here is the caller graph for this function:

◆ swapRB()

void CImage::swapRB ( )

Swaps red and blue channels.

Definition at line 1659 of file CImage.cpp.

References m_impl, and makeSureImageIsLoaded().

Referenced by loadFromXPM(), and mrpt::gui::MRPTImage2wxImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textOut()

void CCanvas::textOut ( int  x0,
int  y0,
const std::string &  str,
const mrpt::img::TColor  color 
)
virtualinherited

Renders 2D text using bitmap fonts.

Parameters
x0The x coordinates
y0The y coordinates
strThe string to put. If using UNICODE characters, use UTF-8 encoding.
colorThe text color
See also
selectTextFont

Reimplemented in mrpt::img::CEnhancedMetaFile.

Definition at line 374 of file CCanvas.cpp.

References mrpt::system::decodeUTF8(), isOriginTopLeft(), mrpt::system::os::memcpy(), MRPT_END, and MRPT_START.

Referenced by drawChessboardCorners(), mrpt::img::CCanvas::drawFeatures(), and mrpt::gui::CDisplayWindow::plot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ triangle()

void CCanvas::triangle ( int  x0,
int  y0,
int  size,
const mrpt::img::TColor  color,
bool  inferior = true,
unsigned int  width = 1 
)
inherited

Draws a triangle.

Parameters
x0The triangle center x coordinate
y0The triangle center y coordinate
sizeThe size of the triangle
colorThe color of the line
inferiorThe position of the triangle
widthThe desired width of the line.
See also
triangle

Definition at line 181 of file CCanvas.cpp.

References mrpt::round(), and mrpt::math::size().

Here is the call graph for this function:

◆ undistort()

void CImage::undistort ( CImage out_img,
const mrpt::img::TCamera cameraParams 
) const

Undistort the image according to some camera parameters, and returns an output undistorted image.

Parameters
out_imgThe output undistorted image
cameraParamsThe input camera params (containing the intrinsic and distortion parameters of the camera)
Note
The intrinsic parameters (fx,fy,cx,cy) of the output image are the same than in the input image.
See also
mrpt::vision::CUndistortMap

Definition at line 1685 of file CImage.cpp.

References ASSERTMSG_, mrpt::img::TCamera::dist, getChannelCount(), mrpt::img::TCamera::intrinsicParams, m_impl, makeSureImageIsLoaded(), and resize().

Referenced by mrpt::hwdrivers::CRovio::captureImageAsync(), and mrpt::obs::CObservation3DRangeScan::undistort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unload()

void CImage::unload ( ) const
noexcept

For external storage image objects only, this method unloads the image from memory (or does nothing if already unloaded).

It does not need to be called explicitly, unless the user wants to save memory for images that will not be used often. If called for an image without the flag "external storage", it is simply ignored.

See also
setExternalStorage, forceLoad

Definition at line 1578 of file CImage.cpp.

References m_imgIsExternalStorage, and m_impl.

◆ update_patch()

void CImage::update_patch ( const CImage patch,
const unsigned int  col,
const unsigned int  row 
)

Update a part of this image with the "patch" given as argument.

The "patch" will be "pasted" at the (col,row) coordinates of this image.

Exceptions
std::exceptionif patch pasted on the pixel (_row, _column) jut out of the image.
See also
extract_patch

Definition at line 1154 of file CImage.cpp.

References m_impl, and makeSureImageIsLoaded().

Here is the call graph for this function:

◆ writeToMatlab()

virtual mxArray* mrpt::serialization::CSerializable::writeToMatlab ( ) const
inlinevirtualinherited

Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class.

Returns
A new mxArray (caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB.

Definition at line 90 of file CSerializable.h.

Member Data Documentation

◆ className

constexpr const char* mrpt::img::CImage::className = "mrpt::img" "::" "CImage"
static

Definition at line 150 of file img/CImage.h.

◆ m_externalFile

std::string mrpt::img::CImage::m_externalFile
mutableprotected

The file name of a external storage image.

Definition at line 1036 of file img/CImage.h.

Referenced by getExternalStorageFile(), getExternalStorageFileAbsolutePath(), makeSureImageIsLoaded(), serializeFrom(), serializeTo(), and swap().

◆ m_imgIsExternalStorage

bool mrpt::img::CImage::m_imgIsExternalStorage {false}
mutableprotected

Set to true only when using setExternalStorage.

See also
setExternalStorage

Definition at line 1033 of file img/CImage.h.

Referenced by getHeight(), getWidth(), isEmpty(), isExternallyStored(), loadFromFile(), loadFromMemoryBuffer(), makeSureImageIsLoaded(), serializeFrom(), serializeTo(), swap(), and unload().

◆ m_impl

mrpt::pimpl<Impl> mrpt::img::CImage::m_impl
protected

◆ m_selectedFont

std::string mrpt::img::CCanvas::m_selectedFont {"9x15"}
protectedinherited

The selected font name.

Definition at line 45 of file CCanvas.h.

◆ m_selectedFontBitmaps

const uint32_t* mrpt::img::CCanvas::m_selectedFontBitmaps {nullptr}
protectedinherited

Direct access to character bitmaps.

Definition at line 48 of file CCanvas.h.

◆ runtimeClassId

const mrpt::rtti::TRuntimeClassId mrpt::img::CImage::runtimeClassId
staticprotected

Definition at line 150 of file img/CImage.h.




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