namespace mrpt::img

Overview

Classes for image storage and manipulation.

namespace img {

// namespaces

namespace mrpt::img::camera_geometry;
    namespace mrpt::img::camera_geometry::distortion;
namespace mrpt::img::detail;

// typedefs

typedef Eigen::Map<const Eigen::Matrix<uint8_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>, Eigen::Unaligned, Eigen::OuterStride<Eigen::Dynamic>> EigenGrayMapConst;
typedef Eigen::Map<Eigen::Matrix<uint8_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>, Eigen::Unaligned, Eigen::OuterStride<Eigen::Dynamic>> EigenGrayMap;
typedef TPixelCoordBase<int32_t> TPixelCoord;
typedef TPixelCoord TImageSize;
typedef TPixelCoordBase<float> TPixelCoordf;

// enums

enum DistortionModel;
enum PixelDepth;
enum TColormap;
enum TImageChannels;
enum TInterpolationMethod;
enum VideoCodec;
enum copy_type_t;
enum ctor_CImage_ref_or_gray;

// structs

struct TColor;
struct TColorf;

template <typename T>
struct TPixelCoordBase;

// classes

class CCanvas;
class CExceptionExternalImageNotFound;
class CImage;
class CImagePyramid;
class CMappedImage;
class CStereoRectifyMap;
class CUndistortMap;
class CVideoFileWriter;
class TCamera;
class TStereoCamera;

// global functions

EigenGrayMapConst asEigenMap(const mrpt::img::CImage& img);
EigenGrayMap asEigenMap(mrpt::img::CImage& img);
cv::Mat toOpenCVMat(mrpt::img::CImage& img);
cv::Mat toOpenCVMat(const mrpt::img::CImage& img);
CImage fromOpenCVMat(const cv::Mat& mat);
mrpt::img::TColorf hsv2rgb(float h, float s, float v);
std::tuple<float, float, float> rgb2hsv(float r, float g, float b);
mrpt::img::TColorf colormap(const TColormap& color_map, float color_index);
mrpt::img::TColorf jet2rgb(float color_index);
mrpt::img::TColorf hot2rgb(float color_index);
void registerAllClasses_mrpt_img();

bool operator == (
    const mrpt::img::TCamera& a,
    const mrpt::img::TCamera& b
    );

bool operator != (
    const mrpt::img::TCamera& a,
    const mrpt::img::TCamera& b
    );

std::ostream& operator << (
    std::ostream& o,
    const TColor& c
    );

mrpt::serialization::CArchive& operator << (
    mrpt::serialization::CArchive& o,
    const TColor& c
    );

mrpt::serialization::CArchive& operator >> (
    mrpt::serialization::CArchive& i,
    TColor& c
    );

TColor operator + (const TColor& a, const TColor& b);
TColor operator - (const TColor& a, const TColor& b);

bool operator == (
    const TColor& a,
    const TColor& b
    );

bool operator != (
    const TColor& a,
    const TColor& b
    );

bool operator == (
    const TColorf& a,
    const TColorf& b
    );

bool operator != (
    const TColorf& a,
    const TColorf& b
    );

std::ostream& operator << (
    std::ostream& o,
    const TColorf& c
    );

mrpt::serialization::CArchive& operator << (
    mrpt::serialization::CArchive& o,
    const TColorf& c
    );

mrpt::serialization::CArchive& operator >> (
    mrpt::serialization::CArchive& i,
    TColorf& c
    );

template <typename T>
std::ostream& operator << (std::ostream& o, const TPixelCoordBase<T>& p);

template std::ostream& operator <<<int > (
    std::ostream&,
    const TPixelCoordBase<int>&
    );

template std::ostream& operator <<<unsigned > (
    std::ostream&,
    const TPixelCoordBase<unsigned>&
    );

template std::ostream& operator <<<float > (
    std::ostream&,
    const TPixelCoordBase<float>&
    );

template std::ostream& operator <<<double > (
    std::ostream&,
    const TPixelCoordBase<double>&
    );

} // namespace img

Typedefs

typedef Eigen::Map<const Eigen::Matrix<uint8_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>, Eigen::Unaligned, Eigen::OuterStride<Eigen::Dynamic>> EigenGrayMapConst

Zero-copy read-only Eigen::Map<RowMajor uint8> over a grayscale CImage.

No memory is allocated; the Map shares the CImage buffer.

Requirements: img must be CH_GRAY, PixelDepth::D8U, and already loaded. The Map remains valid as long as img is alive and not resized.

Row stride is handled via Eigen::OuterStride so images with padding are also supported (though MRPT’s STB backend typically has no padding).

Global Functions

cv::Mat toOpenCVMat(mrpt::img::CImage& img)

Returns a zero-copy, non-owning cv::Mat view over a mutable CImage buffer.

No pixel data is copied. The returned Mat shares the CImage memory and remains valid as long as img is alive and not resized.

Requirements: img must be PixelDepth::D8U (the default) and already loaded. Supports CH_GRAY (CV_8UC1), CH_RGB (CV_8UC3), and CH_RGBA (CV_8UC4).

cv::Mat toOpenCVMat(const mrpt::img::CImage& img)

Returns a zero-copy, read-only cv::Mat view over a const CImage buffer.

The const_cast is safe as long as the Mat is not written to; it exists because cv::Mat has no const-data constructor. Prefer toOpenCVMat() on mutable images; use .clone() if you need an independent copy.

CImage fromOpenCVMat(const cv::Mat& mat)

Copies pixel data from a cv::Mat into a newly allocated CImage.

Supported types: CV_8UC1 (→ CH_GRAY), CV_8UC3 (→ CH_RGB), CV_8UC4 (→ CH_RGBA). The image data is deep-copied; the returned CImage is independent of mat.

TColor operator + (const TColor& a, const TColor& b)

Pairwise addition of their corresponding RGBA members.

TColor operator - (const TColor& a, const TColor& b)

Pairwise substraction of their corresponding RGBA members.

template <typename T>
std::ostream& operator << (std::ostream& o, const TPixelCoordBase<T>& p)

Prints TPixelCoordBase as “(x,y)”.