Visual Servoing Platform  version 3.6.1 under development (2024-03-18)
vpImageConvert Class Reference

#include <visp3/core/vpImageConvert.h>

Static Public Member Functions

static void createDepthHistogram (const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)
 
static void createDepthHistogram (const vpImage< uint16_t > &src_depth, vpImage< unsigned char > &dest_depth)
 
static void createDepthHistogram (const vpImage< float > &src_depth, vpImage< vpRGBa > &dest_depth)
 
static void createDepthHistogram (const vpImage< float > &src_depth, vpImage< unsigned char > &dest_depth)
 
static void convert (const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
 
static void convert (const vpImage< vpRGBa > &src, vpImage< unsigned char > &dest, unsigned int nThreads=0)
 
static void convert (const vpImage< float > &src, vpImage< unsigned char > &dest)
 
static void convert (const vpImage< vpRGBf > &src, vpImage< vpRGBa > &dest)
 
static void convert (const vpImage< unsigned char > &src, vpImage< float > &dest)
 
static void convert (const vpImage< double > &src, vpImage< unsigned char > &dest)
 
static void convert (const vpImage< unsigned char > &src, vpImage< double > &dest)
 
static void convert (const vpImage< uint16_t > &src, vpImage< unsigned char > &dest, unsigned char bitshift=8)
 
static void convert (const vpImage< unsigned char > &src, vpImage< uint16_t > &dest, unsigned char bitshift=8)
 
template<typename Type >
static void convert (const vpImage< Type > &src, vpImage< Type > &dest)
 
static void convert (const cv::Mat &src, vpImage< vpRGBa > &dest, bool flip=false)
 
static void convert (const cv::Mat &src, vpImage< unsigned char > &dest, bool flip=false, unsigned int nThreads=0)
 
static void convert (const cv::Mat &src, vpImage< float > &dest, bool flip=false)
 
static void convert (const cv::Mat &src, vpImage< double > &dest, bool flip=false)
 
static void convert (const cv::Mat &src, vpImage< vpRGBf > &dest, bool flip=false)
 
static void convert (const cv::Mat &src, vpImage< uint16_t > &dest, bool flip=false)
 
static void convert (const vpImage< vpRGBa > &src, cv::Mat &dest)
 
static void convert (const vpImage< unsigned char > &src, cv::Mat &dest, bool copyData=true)
 
static void convert (const vpImage< float > &src, cv::Mat &dest, bool copyData=true)
 
static void convert (const vpImage< double > &src, cv::Mat &dest, bool copyData=true)
 
static void convert (const vpImage< vpRGBf > &src, cv::Mat &dest)
 
static void convert (const vpImage< unsigned char > &src, yarp::sig::ImageOf< yarp::sig::PixelMono > *dest, bool copyData=true)
 
static void convert (const yarp::sig::ImageOf< yarp::sig::PixelMono > *src, vpImage< unsigned char > &dest, bool copyData=true)
 
static void convert (const vpImage< vpRGBa > &src, yarp::sig::ImageOf< yarp::sig::PixelRgba > *dest, bool copyData=true)
 
static void convert (const yarp::sig::ImageOf< yarp::sig::PixelRgba > *src, vpImage< vpRGBa > &dest, bool copyData=true)
 
static void convert (const vpImage< vpRGBa > &src, yarp::sig::ImageOf< yarp::sig::PixelRgb > *dest)
 
static void convert (const yarp::sig::ImageOf< yarp::sig::PixelRgb > *src, vpImage< vpRGBa > &dest)
 
static void split (const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=nullptr)
 
static void merge (const vpImage< unsigned char > *R, const vpImage< unsigned char > *G, const vpImage< unsigned char > *B, const vpImage< unsigned char > *a, vpImage< vpRGBa > &RGBa)
 
static void YUVToRGB (unsigned char y, unsigned char u, unsigned char v, unsigned char &r, unsigned char &g, unsigned char &b)
 
static void YUYVToRGBa (unsigned char *yuyv, unsigned char *rgba, unsigned int width, unsigned int height)
 
static void YUYVToRGB (unsigned char *yuyv, unsigned char *rgb, unsigned int width, unsigned int height)
 
static void YUYVToGrey (unsigned char *yuyv, unsigned char *grey, unsigned int size)
 
static void YUV411ToRGBa (unsigned char *yuv, unsigned char *rgba, unsigned int size)
 
static void YUV411ToRGB (unsigned char *yuv, unsigned char *rgb, unsigned int size)
 
static void YUV411ToGrey (unsigned char *yuv, unsigned char *grey, unsigned int size)
 
static void YUV422ToRGBa (unsigned char *yuv, unsigned char *rgba, unsigned int size)
 
static void YUV422ToRGB (unsigned char *yuv, unsigned char *rgb, unsigned int size)
 
static void YUV422ToGrey (unsigned char *yuv, unsigned char *grey, unsigned int size)
 
static void YUV420ToRGBa (unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
 
static void YUV420ToRGB (unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
 
static void YUV420ToGrey (unsigned char *yuv, unsigned char *grey, unsigned int size)
 
static void YUV444ToRGBa (unsigned char *yuv, unsigned char *rgba, unsigned int size)
 
static void YUV444ToRGB (unsigned char *yuv, unsigned char *rgb, unsigned int size)
 
static void YUV444ToGrey (unsigned char *yuv, unsigned char *grey, unsigned int size)
 
static void YV12ToRGBa (unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
 
static void YV12ToRGB (unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
 
static void YVU9ToRGBa (unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
 
static void YVU9ToRGB (unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
 
static void RGBToRGBa (unsigned char *rgb, unsigned char *rgba, unsigned int size)
 
static void RGBaToRGB (unsigned char *rgba, unsigned char *rgb, unsigned int size)
 
static void RGBToGrey (unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
 
static void RGBToGrey (unsigned char *rgb, unsigned char *grey, unsigned int size)
 
static void RGBaToGrey (unsigned char *rgba, unsigned char *grey, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void RGBaToGrey (unsigned char *rgba, unsigned char *grey, unsigned int size)
 
static void RGBToRGBa (unsigned char *rgb, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
 
static void GreyToRGBa (unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
 
static void GreyToRGBa (unsigned char *grey, unsigned char *rgba, unsigned int size)
 
static void GreyToRGB (unsigned char *grey, unsigned char *rgb, unsigned int size)
 
static void BGRToRGBa (unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
 
static void BGRToGrey (unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
 
static void BGRaToGrey (unsigned char *bgra, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
 
static void BGRaToRGBa (unsigned char *bgra, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
 
static void YCbCrToRGB (unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
 
static void YCbCrToRGBa (unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
 
static void YCbCrToGrey (unsigned char *ycbcr, unsigned char *grey, unsigned int size)
 
static void YCrCbToRGB (unsigned char *ycrcb, unsigned char *rgb, unsigned int size)
 
static void YCrCbToRGBa (unsigned char *ycrcb, unsigned char *rgb, unsigned int size)
 
static void MONO16ToGrey (unsigned char *grey16, unsigned char *grey, unsigned int size)
 
static void MONO16ToRGBa (unsigned char *grey16, unsigned char *rgba, unsigned int size)
 
static void HSVToRGBa (const double *hue, const double *saturation, const double *value, unsigned char *rgba, unsigned int size)
 
static void HSVToRGBa (const unsigned char *hue, const unsigned char *saturation, const unsigned char *value, unsigned char *rgba, unsigned int size)
 
static void RGBaToHSV (const unsigned char *rgba, double *hue, double *saturation, double *value, unsigned int size)
 
static void RGBaToHSV (const unsigned char *rgba, unsigned char *hue, unsigned char *saturation, unsigned char *value, unsigned int size)
 
static void HSVToRGB (const double *hue, const double *saturation, const double *value, unsigned char *rgb, unsigned int size)
 
static void HSVToRGB (const unsigned char *hue, const unsigned char *saturation, const unsigned char *value, unsigned char *rgb, unsigned int size)
 
static void RGBToHSV (const unsigned char *rgb, double *hue, double *saturation, double *value, unsigned int size)
 
static void RGBToHSV (const unsigned char *rgb, unsigned char *hue, unsigned char *saturation, unsigned char *value, unsigned int size)
 
static void demosaicBGGRToRGBaBilinear (const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicBGGRToRGBaBilinear (const uint16_t *bggr, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGBRGToRGBaBilinear (const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGBRGToRGBaBilinear (const uint16_t *gbrg, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGRBGToRGBaBilinear (const uint8_t *grbg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGRBGToRGBaBilinear (const uint16_t *grbg, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicRGGBToRGBaBilinear (const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicRGGBToRGBaBilinear (const uint16_t *rggb, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicBGGRToRGBaMalvar (const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicBGGRToRGBaMalvar (const uint16_t *bggr, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGBRGToRGBaMalvar (const uint8_t *gbrg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGBRGToRGBaMalvar (const uint16_t *gbrg, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGRBGToRGBaMalvar (const uint8_t *grbg, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicGRBGToRGBaMalvar (const uint16_t *grbg, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicRGGBToRGBaMalvar (const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 
static void demosaicRGGBToRGBaMalvar (const uint16_t *rggb, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
 

Detailed Description

Convert image types.

The following example available in tutorial-image-converter.cpp shows how to convert an OpenCV cv::Mat image into a vpImage:

#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif
int main()
{
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
try {
cv::Mat A;
#if VISP_HAVE_OPENCV_VERSION >= 0x030200
int flags = cv::IMREAD_GRAYSCALE | cv::IMREAD_IGNORE_ORIENTATION;
#elif VISP_HAVE_OPENCV_VERSION >= 0x030000
int flags = cv::IMREAD_GRAYSCALE;
#else
int flags = CV_LOAD_IMAGE_GRAYSCALE;
#endif
A = cv::imread("monkey.bmp", flags);
#ifdef VISP_HAVE_PNG
vpImageIo::write(I, "monkey.png"); // Gray
#endif
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#endif
}
error that can be emitted by ViSP classes.
Definition: vpException.h:59
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:287

Definition at line 80 of file vpImageConvert.h.

Member Function Documentation

◆ BGRaToGrey()

void vpImageConvert::BGRaToGrey ( unsigned char *  bgra,
unsigned char *  grey,
unsigned int  width,
unsigned int  height,
bool  flip = false,
unsigned int  nThreads = 0 
)
static

Converts a BGRa image to greyscale. Flips the image vertically if needed. Assumes that grey is already resized.

Note
If flip is false, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]bgra: Pointer to the bitmap containing the 32-bits BGRa data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]width,height: Image size.
[in]flip: When true, image is flipped vertically.
[in]nThreads: When > 0, the value is used to set the number of OpenMP threads used for the conversion.
Examples
testColorConversion.cpp.

Definition at line 4133 of file vpImageConvert.cpp.

Referenced by convert().

◆ BGRaToRGBa()

void vpImageConvert::BGRaToRGBa ( unsigned char *  bgra,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height,
bool  flip = false 
)
static

Converts a BGRa image to RGBa.

Flips the image vertically if needed. Assumes that rgba is already resized before calling this function.

Note
If flip is false, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]bgra: Pointer to the bitmap containing the 32-bits BGRa data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.
[in]flip: When true, image is flipped vertically.
Examples
testColorConversion.cpp.

Definition at line 4023 of file vpImageConvert.cpp.

◆ BGRToGrey()

void vpImageConvert::BGRToGrey ( unsigned char *  bgr,
unsigned char *  grey,
unsigned int  width,
unsigned int  height,
bool  flip = false,
unsigned int  nThreads = 0 
)
static

Converts a BGR image to greyscale. Flips the image vertically if needed. Assumes that grey is already resized.

Note
If flip is false, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]bgr: Pointer to the bitmap containing the 24-bits BGR data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]width,height: Image size.
[in]flip: When true, image is flipped vertically.
[in]nThreads: When > 0, the value is used to set the number of OpenMP threads used for the conversion.
Examples
testColorConversion.cpp.

Definition at line 4071 of file vpImageConvert.cpp.

Referenced by vpV4l2Grabber::acquire(), convert(), vpRobotBebop2::getGrayscaleImage(), and vpRealSense2::getGreyFrame().

◆ BGRToRGBa()

void vpImageConvert::BGRToRGBa ( unsigned char *  bgr,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height,
bool  flip = false 
)
static

Converts a BGR image to RGBa. The alpha component is set to vpRGBa::alpha_default.

Flips the image vertically if needed. Assumes that rgba is already resized.

Note
If flip is false, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]bgr: Pointer to the bitmap containing the 24-bits BGR data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.
[in]flip: When true, image is flipped vertically.

Definition at line 3975 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

Referenced by vpV4l2Grabber::acquire(), vpRealSense2::getColorFrame(), and vpRobotBebop2::getRGBaImage().

◆ convert() [1/27]

void vpImageConvert::convert ( const cv::Mat &  src,
vpImage< double > &  dest,
bool  flip = false 
)
static

Converts cv::Mat CV_32FC1 format to ViSP vpImage<double>.

Parameters
[in]src: OpenCV image in CV_32FC1 format.
[out]dest: ViSP image in double format.
[in]flip: When true during conversion flip image vertically.

Definition at line 553 of file vpImageConvert.cpp.

References convert(), and vpImage< Type >::resize().

◆ convert() [2/27]

void vpImageConvert::convert ( const cv::Mat &  src,
vpImage< float > &  dest,
bool  flip = false 
)
static

Converts cv::Mat CV_32FC1 format to ViSP vpImage<float>.

Parameters
[in]src: OpenCV image in CV_32FC1 format.
[out]dest: ViSP image in float format.
[in]flip: When true during conversion flip image vertically.

Definition at line 524 of file vpImageConvert.cpp.

References vpException::badValue, vpImage< Type >::getCols(), vpImage< Type >::getRows(), and vpImage< Type >::resize().

◆ convert() [3/27]

void vpImageConvert::convert ( const cv::Mat &  src,
vpImage< uint16_t > &  dest,
bool  flip = false 
)
static

Converts cv::Mat CV_16UC1 format to ViSP vpImage<uint16_t>.

Parameters
[in]src: OpenCV image in CV_16UC1 format.
[out]dest: ViSP image in uint16_t format.
[in]flip: When true during conversion flip image vertically.

Definition at line 574 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpException::fatalError, vpImage< Type >::getCols(), vpImage< Type >::getRows(), and vpImage< Type >::resize().

◆ convert() [4/27]

void vpImageConvert::convert ( const cv::Mat &  src,
vpImage< unsigned char > &  dest,
bool  flip = false,
unsigned int  nThreads = 0 
)
static

Convert a cv::Mat to a vpImage<unsigned char>.

A cv::Mat is an OpenCV image class.

Warning
This function is only available if OpenCV was detected during the configuration step.
Parameters
[in]src: Source image in OpenCV format.
[out]dest: Destination image in ViSP format.
[in]flip: Set to true to vertically flip the converted image.
[in]nThreads: number of threads to use if OpenMP is available. If 0 is passed, OpenMP will choose the number of threads.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_OPENCV)
vpImage<unsigned char> Ig; // A grayscale image
cv::Mat Ip;
// Read an image on a disk with openCV library
Ip = cv::imread("image.pgm", cv::IMREAD_GRAYSCALE); // Second parameter for a gray level.
// Convert the grayscale cv::Mat into vpImage<unsigned char>
// ...
#endif
}

Definition at line 445 of file vpImageConvert.cpp.

References BGRaToGrey(), BGRToGrey(), vpImage< Type >::bitmap, vpImage< Type >::getCols(), vpImage< Type >::getRows(), and vpImage< Type >::resize().

◆ convert() [5/27]

void vpImageConvert::convert ( const cv::Mat &  src,
vpImage< vpRGBa > &  dest,
bool  flip = false 
)
static

Convert a cv::Mat to a vpImage<vpRGBa>.

A cv::Mat is an OpenCV image class.

If the input image is of type CV_8UC1 or CV_8UC3, the alpha channel is set to vpRGBa::alpha_default, or 0 in certain case (see the warning below).

Warning
This function is only available if OpenCV (version 2.1.0 or greater) was detected during the configuration step.
If ViSP is built with SSSE3 flag and the CPU supports this intrinsics set, alpha channel will be set to 0, otherwise it will be set to vpRGBa::alpha_default (255).
Parameters
[in]src: Source image in OpenCV format.
[out]dest: Destination image in ViSP format.
[in]flip: Set to true to vertically flip the converted image.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/core/vpRGBa.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_OPENCV)
vpImage<vpRGBa> Ic; // A color image
cv::Mat Ip;
// Read an image on a disk with openCV library
Ip = cv::imread("image.pgm", cv::IMREAD_COLOR); // Second parameter for a BGR encoding.
// Convert the grayscale cv::Mat into vpImage<vpRGBa>
// ...
#endif
}

Definition at line 333 of file vpImageConvert.cpp.

References vpRGBa::A, vpRGBa::alpha_default, vpRGBa::B, vpImage< Type >::bitmap, vpRGBa::G, vpImage< Type >::getCols(), vpImage< Type >::getRows(), vpImage< Type >::getWidth(), vpRGBa::R, and vpImage< Type >::resize().

◆ convert() [6/27]

void vpImageConvert::convert ( const cv::Mat &  src,
vpImage< vpRGBf > &  dest,
bool  flip = false 
)
static

Converts cv::Mat CV_32FC3 format to ViSP vpImage<vpRGBf>.

Parameters
[in]src: OpenCV image in CV_32FC3 format.
[out]dest: ViSP image in vpRGBf format.
[in]flip: When true during conversion flip image vertically.

Definition at line 609 of file vpImageConvert.cpp.

References vpRGBf::B, vpException::badValue, vpRGBf::G, vpImage< Type >::getCols(), vpImage< Type >::getRows(), vpRGBf::R, and vpImage< Type >::resize().

◆ convert() [7/27]

void vpImageConvert::convert ( const vpImage< double > &  src,
cv::Mat &  dest,
bool  copyData = true 
)
static

◆ convert() [8/27]

void vpImageConvert::convert ( const vpImage< double > &  src,
vpImage< unsigned char > &  dest 
)
static

Convert a vpImage<double> to a vpImage<unsigned char> by renormalizing between 0 and 255.

Parameters
[in]src: Source image
[out]dest: Destination image.

Definition at line 176 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getMinMaxValue(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [9/27]

void vpImageConvert::convert ( const vpImage< float > &  src,
cv::Mat &  dest,
bool  copyData = true 
)
static

◆ convert() [10/27]

void vpImageConvert::convert ( const vpImage< float > &  src,
vpImage< unsigned char > &  dest 
)
static

Convert a vpImage<float> to a vpImage<unsigned char> by renormalizing between 0 and 255.

Parameters
[in]src: Source image
[out]dest: Destination image.

Definition at line 101 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getMinMaxValue(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [11/27]

template<typename Type >
static void vpImageConvert::convert ( const vpImage< Type > &  src,
vpImage< Type > &  dest 
)
inlinestatic

Make a copy of an image.

Parameters
src: source image.
dest: destination image.

Definition at line 108 of file vpImageConvert.h.

◆ convert() [12/27]

void vpImageConvert::convert ( const vpImage< uint16_t > &  src,
vpImage< unsigned char > &  dest,
unsigned char  bitshift = 8 
)
static

Convert a vpImage<uint16_t> to a vpImage<unsigned char>.

Parameters
[in]src: Source image
[out]dest: Destination image.
[in]bitshift: Right bit shift applied to each source element.

Definition at line 204 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [13/27]

void vpImageConvert::convert ( const vpImage< unsigned char > &  src,
cv::Mat &  dest,
bool  copyData = true 
)
static

Convert a vpImage<unsigned char> to a cv::Mat grey level image.

A cv::Mat is an OpenCV image class. See http://opencv.willowgarage.com for the general OpenCV documentation, or http://opencv.willowgarage.com/documentation/cpp/core_basic_structures.html for the specific Mat structure documentation.

Warning
This function is only available if OpenCV version 2.1.0 or greater was detected during the configuration step.
Parameters
[in]src: Source image.
[out]dest: Destination image.
[in]copyData: If true, the image is copied and modification in one object will not modified the other.
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
vpImage<unsigned char> Ig; // A grayscale image
cv::Mat Ip;
// Read an image on a disk
vpImageIo::read(Ig, "image.pgm");
// Convert the vpImage<unsigned char> in to grayscale cv::Mat
// Treatments on cv::Mat Ip
//...
// Save the cv::Mat on the disk
cv::imwrite("image-cv.pgm", Ip);
#endif
}
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:143

Definition at line 716 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getCols(), and vpImage< Type >::getRows().

◆ convert() [14/27]

void vpImageConvert::convert ( const vpImage< unsigned char > &  src,
vpImage< double > &  dest 
)
static

Convert a vpImage<unsigned char> to a vpImage<double> by basic casting.

Parameters
[in]src: Source image
[out]dest: Destination image.

Definition at line 235 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [15/27]

void vpImageConvert::convert ( const vpImage< unsigned char > &  src,
vpImage< float > &  dest 
)
static

Convert a vpImage<unsigned char> to a vpImage<float> by basic casting.

Parameters
[in]src: Source image
[out]dest: Destination image.

Definition at line 160 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [16/27]

void vpImageConvert::convert ( const vpImage< unsigned char > &  src,
vpImage< uint16_t > &  dest,
unsigned char  bitshift = 8 
)
static

Convert a vpImage<unsigned char> to a vpImage<uint16_t>.

Parameters
[in]src: Source image
[out]dest: Destination image.
[in]bitshift: Left bit shift applied to each source element.

Definition at line 220 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [17/27]

void vpImageConvert::convert ( const vpImage< unsigned char > &  src,
vpImage< vpRGBa > &  dest 
)
static

Convert a vpImage<unsigned char> to a vpImage<vpRGBa>. Tha alpha component is set to vpRGBa::alpha_default.

Parameters
[in]src: Source image
[out]dest: Destination image.
See also
GreyToRGBa()
Examples
AROgre.cpp, AROgreBasic.cpp, HelloWorldOgre.cpp, HelloWorldOgreAdvanced.cpp, grabV4l2MultiCpp11Thread.cpp, readRealSenseData.cpp, saveRealSenseData.cpp, servoPioneerPoint2DDepth.cpp, servoPioneerPoint2DDepthWithoutVpServo.cpp, servoViper850FourPointsKinect.cpp, testColorConversion.cpp, testConnectedComponents.cpp, testContours.cpp, testConversion.cpp, testFloodFill.cpp, testGaussianFilter.cpp, testGenericTracker.cpp, testImageFilter.cpp, testImageNormalizedCorrelation.cpp, testKeyPoint-3.cpp, testKeyPoint-4.cpp, testRealSense2_SR300.cpp, testUndistortImage.cpp, trackKltOpencv.cpp, tutorial-apriltag-detector-live-rgbd-realsense.cpp, tutorial-apriltag-detector-live-rgbd-structure-core.cpp, tutorial-apriltag-detector-live.cpp, tutorial-apriltag-detector.cpp, tutorial-barcode-detector-live.cpp, tutorial-blob-tracker-live-firewire.cpp, tutorial-blob-tracker-live-v4l2.cpp, tutorial-bridge-opencv-camera-param.cpp, tutorial-bridge-opencv-image.cpp, tutorial-brightness-adjustment.cpp, tutorial-circle-hough.cpp, tutorial-dnn-object-detection-live.cpp, tutorial-face-detector-live-threaded.cpp, tutorial-face-detector-live.cpp, tutorial-grabber-opencv-threaded.cpp, tutorial-grabber-opencv.cpp, tutorial-ibvs-4pts-ogre-tracking.cpp, tutorial-image-converter.cpp, tutorial-image-filter.cpp, tutorial-klt-tracker-live-v4l2.cpp, tutorial-klt-tracker-with-reinit.cpp, tutorial-klt-tracker.cpp, tutorial-mb-generic-tracker-apriltag-rs2.cpp, tutorial-mb-generic-tracker-apriltag-webcam.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-mb-generic-tracker-rgbd-realsense-json.cpp, tutorial-mb-generic-tracker-rgbd-realsense.cpp, tutorial-mb-generic-tracker-rgbd-structure-core.cpp, tutorial-mb-generic-tracker-rgbd.cpp, tutorial-me-ellipse-tracker.cpp, tutorial-me-line-tracker.cpp, tutorial-megapose-live-single-object-tracking.cpp, tutorial-pose-from-points-live.cpp, tutorial-video-manipulation.cpp, and tutorial-video-recorder.cpp.

Definition at line 72 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), GreyToRGBa(), and vpImage< Type >::resize().

Referenced by vpVideoReader::acquire(), vpKeyPoint::buildReference(), vpImageFilter::canny(), vpMbGenericTracker::computeCurrentProjectionError(), vpImageFilter::computePartialDerivatives(), convert(), vpDetectorFace::detect(), vpKeyPoint::detect(), vpCircleHoughTransform::detect(), vpCannyEdgeDetection::detect(), vpKeyPoint::detectExtractAffine(), drawingHelpers::display(), vpKeyPoint::extract(), vpVideoReader::getFrame(), vpImageFilter::getGaussPyramidal(), vpDisplay::getImage(), vpDisplayOpenCV::getImage(), vpImageSimulator::init(), vpMbGenericTracker::initClick(), vpMbTracker::initFromPoints(), vpMbTracker::initFromPose(), vpKeyPoint::insertImageMatching(), vpKeyPoint::matchPoint(), vpImageFilter::median(), vpMbKltTracker::preTracking(), vpMbKltTracker::reinit(), vpVideoWriter::saveFrame(), vpMbKltTracker::setPose(), vpMbDepthDenseTracker::setPose(), vpMbDepthNormalTracker::setPose(), vpMbEdgeKltTracker::setPose(), vpMbEdgeTracker::setPose(), vpMbGenericTracker::setPose(), vpImageTools::templateMatching(), vpMbEdgeTracker::track(), vpMbEdgeKltTracker::track(), vpMbKltTracker::track(), and vpMbGenericTracker::track().

◆ convert() [18/27]

void vpImageConvert::convert ( const vpImage< unsigned char > &  src,
yarp::sig::ImageOf< yarp::sig::PixelMono > *  dest,
bool  copyData = true 
)
static

Convert a vpImage<unsigned char> to a yarp::sig::ImageOf<yarp::sig::PixelMono>

A yarp::sig::Image is a YARP image class. See http://eris.liralab.it/yarpdoc/df/d15/classyarp_1_1sig_1_1Image.html for the YARP image class documentation.

Parameters
[in]src: Source image in ViSP format.
[out]dest: Destination image in YARP format.
[in]copyData: Set to true to copy all the image content. If false we only update the image pointer.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_YARP)
vpImage<unsigned char> I; // A mocochrome image
// Read an image on a disk
vpImageIo::read(I, "image.pgm");
yarp::sig::ImageOf< yarp::sig::PixelMono > *Iyarp = new yarp::sig::ImageOf<yarp::sig::PixelMono >();
// Convert the vpImage<unsigned char> to a yarp::sig::ImageOf<yarp::sig::PixelMono>
// ...
#endif
}

Definition at line 793 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getCols(), vpImage< Type >::getHeight(), vpImage< Type >::getRows(), and vpImage< Type >::getWidth().

◆ convert() [19/27]

void vpImageConvert::convert ( const vpImage< vpRGBa > &  src,
cv::Mat &  dest 
)
static

Convert a vpImage<vpRGBa> to a cv::Mat color image.

A cv::Mat is an OpenCV image class. See http://opencv.willowgarage.com for the general OpenCV documentation, or http://opencv.willowgarage.com/documentation/cpp/core_basic_structures.html for the specific Mat structure documentation.

Warning
This function is only available if OpenCV version 2.1.0 or greater was detected during the configuration step.
Parameters
[in]src: Source image (vpRGBa format).
[out]dest: Destination image (BGR format).
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_OPENCV)
vpImage<vpRGBa> I; // A color image
cv::Mat Icv;
// Read an image on a disk
vpImageIo::read(I, "image.ppm");
// Convert the image into color cv::Mat.
// Treatments on cv::Mat Icv
//...
// Save the cv::Mat on the disk
cv::imwrite("image-cv.ppm", Icv);
#endif
}

Definition at line 672 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getCols(), and vpImage< Type >::getRows().

◆ convert() [20/27]

void vpImageConvert::convert ( const vpImage< vpRGBa > &  src,
vpImage< unsigned char > &  dest,
unsigned int  nThreads = 0 
)
static

Convert a vpImage<unsigned char> to a vpImage<vpRGBa>

Parameters
[in]src: Source image
[out]dest: Destination image.
[in]nThreads: Number of threads to use if OpenMP is available. If 0 is passed, OpenMP will choose the number of threads.
See also
RGBaToGrey()

Definition at line 88 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpImage< Type >::resize(), and RGBaToGrey().

◆ convert() [21/27]

void vpImageConvert::convert ( const vpImage< vpRGBa > &  src,
yarp::sig::ImageOf< yarp::sig::PixelRgb > *  dest 
)
static

Convert a vpImage<vpRGBa> to a yarp::sig::ImageOf<yarp::sig::PixelRgb>

A yarp::sig::Image is a YARP image class. See http://eris.liralab.it/yarpdoc/df/d15/classyarp_1_1sig_1_1Image.html for the YARP image class documentation.

Parameters
[in]src: Source image in ViSP format.
[out]dest: Destination image in YARP format.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/core/vpRGBa.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_YARP)
vpImage<vpRGBa> I; // A color image
// Read an image on a disk
vpImageIo::read(I,"image.jpg");
yarp::sig::ImageOf< yarp::sig::PixelRgb > *Iyarp = new yarp::sig::ImageOf<yarp::sig::PixelRgb >();
// Convert the vpImage<vpRGBa> to a yarp::sig::ImageOf<yarp::sig::PixelRgb>
// ...
#endif
}

Definition at line 980 of file vpImageConvert.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getRows(), and vpImage< Type >::getWidth().

◆ convert() [22/27]

void vpImageConvert::convert ( const vpImage< vpRGBa > &  src,
yarp::sig::ImageOf< yarp::sig::PixelRgba > *  dest,
bool  copyData = true 
)
static

Convert a vpImage<vpRGBa> to a yarp::sig::ImageOf<yarp::sig::PixelRgba>

A yarp::sig::Image is a YARP image class. See http://eris.liralab.it/yarpdoc/df/d15/classyarp_1_1sig_1_1Image.html for the YARP image class documentation.

Parameters
[in]src: Source image in ViSP format.
[in]dest: Destination image in YARP format.
[in]copyData: Set to true to copy all the image content. If false we only update the image pointer.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/core/vpRGBa.h>
#include <visp3/io/vpImageIo.h>
int main()
{
#if defined(VISP_HAVE_YARP)
vpImage<vpRGBa> I; // A color image
// Read an image on a disk
vpImageIo::read(I,"image.jpg");
yarp::sig::ImageOf< yarp::sig::PixelRgba > *Iyarp = new yarp::sig::ImageOf<yarp::sig::PixelRgba >();
// Convert the vpImage<vpRGBa> to a yarp::sig::ImageOf<yarp::sig::PixelRgba>
// ...
#endif
}

Definition at line 889 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getCols(), vpImage< Type >::getHeight(), vpImage< Type >::getRows(), and vpImage< Type >::getWidth().

◆ convert() [23/27]

void vpImageConvert::convert ( const vpImage< vpRGBf > &  src,
cv::Mat &  dest 
)
static

◆ convert() [24/27]

void vpImageConvert::convert ( const vpImage< vpRGBf > &  src,
vpImage< vpRGBa > &  dest 
)
static

Convert a vpImage<vpRGBf> to a vpImage<unsigned char> by renormalizing between 0 and 255.

Parameters
[in]src: Source image
[out]dest: Destination image.

Definition at line 129 of file vpImageConvert.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getMinMaxValue(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ convert() [25/27]

void vpImageConvert::convert ( const yarp::sig::ImageOf< yarp::sig::PixelMono > *  src,
vpImage< unsigned char > &  dest,
bool  copyData = true 
)
static

Convert a yarp::sig::ImageOf<yarp::sig::PixelMono> to a vpImage<unsigned char>

A yarp::sig::Image is a YARP image class. See http://eris.liralab.it/yarpdoc/df/d15/classyarp_1_1sig_1_1Image.html for the YARP image class documentation.

Parameters
[in]src: Source image in YARP format.
[out]dest: Destination image in ViSP format.
[in]copyData: Set to true to copy all the image content. If false we only update the image pointer.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
#if defined(VISP_HAVE_YARP)
#include <yarp/sig/ImageFile.h>
#endif
int main()
{
#if defined(VISP_HAVE_YARP)
yarp::sig::ImageOf< yarp::sig::PixelMono > *Iyarp = new yarp::sig::ImageOf<yarp::sig::PixelMono >();
// Read an image on a disk
yarp::sig::file::read(*Iyarp, "image.pgm");
// Convert the yarp::sig::ImageOf<yarp::sig::PixelMono> to a vpImage<unsigned char>
// ...
#endif
}

Definition at line 843 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, and vpImage< Type >::resize().

◆ convert() [26/27]

void vpImageConvert::convert ( const yarp::sig::ImageOf< yarp::sig::PixelRgb > *  src,
vpImage< vpRGBa > &  dest 
)
static

Convert a yarp::sig::ImageOf<yarp::sig::PixelRgb> to a vpImage<vpRGBa>

A yarp::sig::Image is a YARP image class. See http://eris.liralab.it/yarpdoc/df/d15/classyarp_1_1sig_1_1Image.html for the YARP image class documentation.

The alpha component of the resulting image is set to vpRGBa::alpha_default.

Parameters
[in]src: Source image in YARP format.
[out]dest: Destination image in ViSP format.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/core/vpRGBa.h>
#include <visp3/io/vpImageIo.h>
#if defined(VISP_HAVE_YARP)
#include <yarp/sig/ImageFile.h>
#endif
int main()
{
#if defined(VISP_HAVE_YARP)
yarp::sig::ImageOf< yarp::sig::PixelRgb > *Iyarp = new yarp::sig::ImageOf<yarp::sig::PixelRgb >();
// Read an image on a disk
yarp::sig::file::read(*Iyarp,"image.pgm");
// Convert the yarp::sig::ImageOf<yarp::sig::PixelRgb> to a vpImage<vpRGBa>
// ...
#endif
}

Definition at line 1031 of file vpImageConvert.cpp.

References vpRGBa::alpha_default, and vpImage< Type >::resize().

◆ convert() [27/27]

void vpImageConvert::convert ( const yarp::sig::ImageOf< yarp::sig::PixelRgba > *  src,
vpImage< vpRGBa > &  dest,
bool  copyData = true 
)
static

Convert a yarp::sig::ImageOf<yarp::sig::PixelRgba> to a vpImage<vpRGBa>

A yarp::sig::Image is a YARP image class. See http://eris.liralab.it/yarpdoc/df/d15/classyarp_1_1sig_1_1Image.html for the YARP image class documentation.

Parameters
[in]src: Source image in YARP format.
[out]dest: Destination image in ViSP format.
[in]copyData: Set to true to copy all the image content. If false we only update the image pointer.
#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/core/vpRGBa.h>
#include <visp3/io/vpImageIo.h>
#if defined(VISP_HAVE_YARP)
#include <yarp/sig/ImageFile.h>
#endif
int main()
{
#if defined(VISP_HAVE_YARP)
yarp::sig::ImageOf< yarp::sig::PixelRgba > *Iyarp = new yarp::sig::ImageOf<yarp::sig::PixelRgba >();
// Read an image on a disk
yarp::sig::file::read(*Iyarp,"image.pgm");
// Convert the yarp::sig::ImageOf<yarp::sig::PixelRgba> to a vpImage<vpRGBa>
// ...
#endif
}

Definition at line 938 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, and vpImage< Type >::resize().

◆ createDepthHistogram() [1/4]

void vpImageConvert::createDepthHistogram ( const vpImage< float > &  src_depth,
vpImage< unsigned char > &  dest_depth 
)
static

Convert the input float depth image to a 8-bits depth image. The input depth value is assigned a value proportional to its frequency.

Parameters
[in]src_depth: Input float depth image.
[out]dest_depth: Output grayscale depth image.

Definition at line 286 of file vpImageConvert.cpp.

◆ createDepthHistogram() [2/4]

void vpImageConvert::createDepthHistogram ( const vpImage< float > &  src_depth,
vpImage< vpRGBa > &  dest_rgba 
)
static

Convert the input float depth image to a color depth image. The input depth value is assigned a color value proportional to its frequency. The alpha component of the resulting image is set to vpRGBa::alpha_default.

Parameters
[in]src_depth: Input float depth image.
[out]dest_rgba: Output color depth image.

Definition at line 275 of file vpImageConvert.cpp.

◆ createDepthHistogram() [3/4]

void vpImageConvert::createDepthHistogram ( const vpImage< uint16_t > &  src_depth,
vpImage< unsigned char > &  dest_depth 
)
static

Convert the input 16-bits depth image to a 8-bits depth image. The input depth value is assigned a value proportional to its frequency.

Parameters
[in]src_depth: Input 16-bits depth image.
[out]dest_depth: Output grayscale depth image.

Definition at line 263 of file vpImageConvert.cpp.

◆ createDepthHistogram() [4/4]

◆ demosaicBGGRToRGBaBilinear() [1/2]

void vpImageConvert::demosaicBGGRToRGBaBilinear ( const uint16_t *  bggr,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]bggr: Array of Bayer data arranged into BGGR pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5065 of file vpImageConvert.cpp.

◆ demosaicBGGRToRGBaBilinear() [2/2]

void vpImageConvert::demosaicBGGRToRGBaBilinear ( const uint8_t *  bggr,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]bggr: Array of Bayer data arranged into BGGR pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5047 of file vpImageConvert.cpp.

◆ demosaicBGGRToRGBaMalvar() [1/2]

void vpImageConvert::demosaicBGGRToRGBaMalvar ( const uint16_t *  bggr,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]bggr: Array of Bayer data arranged into BGGR pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5211 of file vpImageConvert.cpp.

◆ demosaicBGGRToRGBaMalvar() [2/2]

void vpImageConvert::demosaicBGGRToRGBaMalvar ( const uint8_t *  bggr,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]bggr: Array of Bayer data arranged into BGGR pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5193 of file vpImageConvert.cpp.

◆ demosaicGBRGToRGBaBilinear() [1/2]

void vpImageConvert::demosaicGBRGToRGBaBilinear ( const uint16_t *  gbrg,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]gbrg: Array of Bayer data arranged into GBRG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5101 of file vpImageConvert.cpp.

◆ demosaicGBRGToRGBaBilinear() [2/2]

void vpImageConvert::demosaicGBRGToRGBaBilinear ( const uint8_t *  gbrg,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]gbrg: Array of Bayer data arranged into GBRG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5083 of file vpImageConvert.cpp.

◆ demosaicGBRGToRGBaMalvar() [1/2]

void vpImageConvert::demosaicGBRGToRGBaMalvar ( const uint16_t *  gbrg,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]gbrg: Array of Bayer data arranged into GBRG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5247 of file vpImageConvert.cpp.

◆ demosaicGBRGToRGBaMalvar() [2/2]

void vpImageConvert::demosaicGBRGToRGBaMalvar ( const uint8_t *  gbrg,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]gbrg: Array of Bayer data arranged into GBRG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5229 of file vpImageConvert.cpp.

◆ demosaicGRBGToRGBaBilinear() [1/2]

void vpImageConvert::demosaicGRBGToRGBaBilinear ( const uint16_t *  grbg,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]grbg: Array of Bayer data arranged into GRBG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5137 of file vpImageConvert.cpp.

◆ demosaicGRBGToRGBaBilinear() [2/2]

void vpImageConvert::demosaicGRBGToRGBaBilinear ( const uint8_t *  grbg,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]grbg: Array of Bayer data arranged into GRBG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5119 of file vpImageConvert.cpp.

◆ demosaicGRBGToRGBaMalvar() [1/2]

void vpImageConvert::demosaicGRBGToRGBaMalvar ( const uint16_t *  grbg,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]grbg: Array of Bayer data arranged into GRBG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5283 of file vpImageConvert.cpp.

◆ demosaicGRBGToRGBaMalvar() [2/2]

void vpImageConvert::demosaicGRBGToRGBaMalvar ( const uint8_t *  grbg,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]grbg: Array of Bayer data arranged into GRBG pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5265 of file vpImageConvert.cpp.

◆ demosaicRGGBToRGBaBilinear() [1/2]

void vpImageConvert::demosaicRGGBToRGBaBilinear ( const uint16_t *  rggb,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]rggb: Array of Bayer data arranged into RGGB pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5173 of file vpImageConvert.cpp.

◆ demosaicRGGBToRGBaBilinear() [2/2]

void vpImageConvert::demosaicRGGBToRGBaBilinear ( const uint8_t *  rggb,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method.

Parameters
[in]rggb: Array of Bayer data arranged into RGGB pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5155 of file vpImageConvert.cpp.

◆ demosaicRGGBToRGBaMalvar() [1/2]

void vpImageConvert::demosaicRGGBToRGBaMalvar ( const uint16_t *  rggb,
uint16_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint16 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]rggb: Array of Bayer data arranged into RGGB pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.

Definition at line 5319 of file vpImageConvert.cpp.

◆ demosaicRGGBToRGBaMalvar() [2/2]

void vpImageConvert::demosaicRGGBToRGBaMalvar ( const uint8_t *  rggb,
uint8_t *  rgba,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using Malvar [29] demosaicing method.

Parameters
[in]rggb: Array of Bayer data arranged into RGGB pattern.
[out]rgba: Array of R, G, B and A values converted from Bayer image.
[in]width: Bayer image width.
[in]height: Bayer image height.
[in]nThreads: Number of OpenMP threads to use if available.
Note
rgba array must be preallocated beforehand. Alpha channel is left as-is.
Examples
testColorConversion.cpp.

Definition at line 5301 of file vpImageConvert.cpp.

◆ GreyToRGB()

void vpImageConvert::GreyToRGB ( unsigned char *  grey,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert from grey image to linear RGB image.

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]grey: Pointer to the bitmap containing the 8-bits grey data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]size: Image size corresponding to image width * height.

Definition at line 3939 of file vpImageConvert.cpp.

◆ GreyToRGBa() [1/2]

void vpImageConvert::GreyToRGBa ( unsigned char *  grey,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert from grey image to linear RGBa image. The alpha component is set to vpRGBa::alpha_default.

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]grey: Pointer to the bitmap containing the 8-bits grey data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to image width * height.

Definition at line 3907 of file vpImageConvert.cpp.

References vpRGBa::alpha_default, and GreyToRGBa().

◆ GreyToRGBa() [2/2]

void vpImageConvert::GreyToRGBa ( unsigned char *  grey,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height 
)
static

Convert from grey image to linear RGBa image. The alpha component is set to vpRGBa::alpha_default.

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]grey: Pointer to the bitmap containing the 8-bits grey data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.

Definition at line 3886 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

Referenced by vp1394CMUGrabber::acquire(), vpV4l2Grabber::acquire(), vp1394TwoGrabber::acquire(), vpOccipitalStructure::acquire(), convert(), vp1394TwoGrabber::dequeue(), and GreyToRGBa().

◆ HSVToRGB() [1/2]

void vpImageConvert::HSVToRGB ( const double *  hue,
const double *  saturation,
const double *  value,
unsigned char *  rgb,
unsigned int  size 
)
static

Converts an array of hue, saturation and value to an array of RGB values.

Parameters
[in]hue: Array of hue values (range between [0 - 1]).
[in]saturation: Array of saturation values (range between [0 - 1]).
[in]value: Array of value values (range between [0 - 1]).
[out]rgb: Pointer to the 24-bit RGB image that should be allocated with a size of width * height * 3.
[in]size: The image size or the number of pixels corresponding to the image width * height.
Examples
testDisplayPolygonLines.cpp.

Definition at line 4970 of file vpImageConvert.cpp.

Referenced by HSVToRGB().

◆ HSVToRGB() [2/2]

void vpImageConvert::HSVToRGB ( const unsigned char *  hue,
const unsigned char *  saturation,
const unsigned char *  value,
unsigned char *  rgb,
unsigned int  size 
)
static

Converts an array of hue, saturation and value to an array of RGB values.

Parameters
[in]hue: Array of hue values (range between [0 - 255]).
[in]saturation: Array of saturation values (range between [0 - 255]).
[in]value: Array of value values (range between [0 - 255]).
[out]rgb: Pointer to the 24-bit RGB image that should be allocated with a size of width * height * 3.
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 4985 of file vpImageConvert.cpp.

References HSVToRGB().

◆ HSVToRGBa() [1/2]

void vpImageConvert::HSVToRGBa ( const double *  hue,
const double *  saturation,
const double *  value,
unsigned char *  rgba,
unsigned int  size 
)
static

Converts an array of hue, saturation and value to an array of RGBa values.

Alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]hue: Array of hue values (range between [0 - 1]).
[in]saturation: Array of saturation values (range between [0 - 1]).
[in]value: Array of value values (range between [0 - 1]).
[out]rgba: Pointer to the 32-bit RGBA image that should be allocated with a size of width * height * 4. Alpha channel is here set to vpRGBa::alpha_default.
[in]size: The image size or the number of pixels corresponding to the image width * height.
Examples
testConversion.cpp.

Definition at line 4890 of file vpImageConvert.cpp.

Referenced by vp::equalizeHistogram(), vp::gammaCorrection(), HSVToRGBa(), and vp::stretchContrastHSV().

◆ HSVToRGBa() [2/2]

void vpImageConvert::HSVToRGBa ( const unsigned char *  hue,
const unsigned char *  saturation,
const unsigned char *  value,
unsigned char *  rgba,
unsigned int  size 
)
static

Converts an array of hue, saturation and value to an array of RGBa values.

Alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]hue: Array of hue values (range between [0 - 255]).
[in]saturation: Array of saturation values (range between [0 - 255]).
[in]value: Array of value values (range between [0 - 255]).
[out]rgba: Pointer to the 32-bit RGBA image that should be allocated with a size of width * height * 4. Alpha channel is here set to vpRGBa::alpha_default.
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 4908 of file vpImageConvert.cpp.

References HSVToRGBa().

◆ merge()

void vpImageConvert::merge ( const vpImage< unsigned char > *  R,
const vpImage< unsigned char > *  G,
const vpImage< unsigned char > *  B,
const vpImage< unsigned char > *  a,
vpImage< vpRGBa > &  RGBa 
)
static

Merge 4 channels into an RGBa image.

Parameters
[in]R: Red channel.
[in]G: Green channel.
[in]B: Blue channel.
[in]a: Alpha channel.
[out]RGBa: Destination RGBa image. Image is resized internally if needed.
Note
If R, G, B, a are provided, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Examples
grabV4l2MultiCpp11Thread.cpp, testColorConversion.cpp, and testConversion.cpp.

Definition at line 4609 of file vpImageConvert.cpp.

References vpRGBa::A, vpRGBa::B, vpImage< Type >::bitmap, vpException::dimensionError, vpRGBa::G, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpRGBa::R, and vpImage< Type >::resize().

Referenced by vp::gammaCorrection().

◆ MONO16ToGrey()

void vpImageConvert::MONO16ToGrey ( unsigned char *  grey16,
unsigned char *  grey,
unsigned int  size 
)
static

Converts a MONO16 grey scale image (each pixel is coded by two bytes) into a grey image where each pixels are coded on one byte.

Parameters
[in]grey16: Input image to convert (two bytes per pixel).
[out]grey: Pointer to the 8-bit grey image (one byte per pixel) that should be allocated with a size of width * height.
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 4685 of file vpImageConvert.cpp.

Referenced by vp1394CMUGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ MONO16ToRGBa()

void vpImageConvert::MONO16ToRGBa ( unsigned char *  grey16,
unsigned char *  rgba,
unsigned int  size 
)
static

Converts a MONO16 grey scale image (each pixel is coded by two bytes) into a grey image where each pixels are coded on one byte.

Alpha component is set to vpRGBa::alpha_default.

Parameters
[in]grey16: Pointer to the bitmap containing the input image to convert (two bytes per pixel).
[out]rgba: Pointer to the 32-bit RGBA image that should be allocated with a size of width * height * 4.
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 4707 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

Referenced by vp1394CMUGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ RGBaToGrey() [1/2]

void vpImageConvert::RGBaToGrey ( unsigned char *  rgba,
unsigned char *  grey,
unsigned int  size 
)
static

Convert a RGBa image to a greyscale one.

See Charles Pontyon's Colour FAQ http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]rgba: Pointer to the 32-bits RGBA bitmap.
[out]grey: Pointer to the bitmap containing the 8-bits grey data that should be allocated with a size of width * height.
[in]size: Image size corresponding to image width * height.

Definition at line 3858 of file vpImageConvert.cpp.

◆ RGBaToGrey() [2/2]

void vpImageConvert::RGBaToGrey ( unsigned char *  rgba,
unsigned char *  grey,
unsigned int  width,
unsigned int  height,
unsigned int  nThreads = 0 
)
static

Convert a RGBa image to a grey scale one.

See Charles Pontyon's Colour FAQ http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]rgba: Pointer to the 32-bits RGBA bitmap.
[out]grey: Pointer to the bitmap containing the 8-bits grey data that should be allocated with a size of width * height.
[in]width,height: Image size.
[in]nThreads: When > 0, the value is used to set the number of OpenMP threads used for the conversion.

Definition at line 3818 of file vpImageConvert.cpp.

Referenced by vpV4l2Grabber::acquire(), convert(), and vpRealSense2::getGreyFrame().

◆ RGBaToHSV() [1/2]

void vpImageConvert::RGBaToHSV ( const unsigned char *  rgba,
double *  hue,
double *  saturation,
double *  value,
unsigned int  size 
)
static

Converts an array of RGBa to an array of hue, saturation, value values. The alpha channel is not used.

Parameters
[in]rgba: Pointer to the 32-bits RGBA bitmap.
[out]hue: Array of hue values converted from RGB color space (range between [0 - 1]).
[out]saturation: Array of saturation values converted from RGB color space (range between [0 - 1]).
[out]value: Array of value values converted from RGB color space (range between [0 - 1]).
[in]size: The image size or the number of pixels corresponding to the image width * height.
Examples
testConversion.cpp.

Definition at line 4930 of file vpImageConvert.cpp.

Referenced by vp::equalizeHistogram(), vp::gammaCorrection(), RGBaToHSV(), and vp::stretchContrastHSV().

◆ RGBaToHSV() [2/2]

void vpImageConvert::RGBaToHSV ( const unsigned char *  rgba,
unsigned char *  hue,
unsigned char *  saturation,
unsigned char *  value,
unsigned int  size 
)
static

Converts an array of RGBa to an array of hue, saturation, value values. The alpha channel is not used.

Parameters
[in]rgba: Pointer to the 32-bits RGBA bitmap.
[out]hue: Array of hue values converted from RGB color space (range between [0 - 255]).
[out]saturation: Array of saturation values converted from RGB color space (range between [0 - 255]).
[out]value: Array of value values converted from RGB color space (range between [0 - 255]).
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 4947 of file vpImageConvert.cpp.

References RGBaToHSV().

◆ RGBaToRGB()

void vpImageConvert::RGBaToRGB ( unsigned char *  rgba,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert RGB image into RGBa image.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]rgba: Pointer to the 32-bits RGBA bitmap.
[out]rgb: Pointer to the bitmap containing the 24-bits RGB data that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to image width * height.
Examples
testColorConversion.cpp, and testConversion.cpp.

Definition at line 3717 of file vpImageConvert.cpp.

◆ RGBToGrey() [1/2]

void vpImageConvert::RGBToGrey ( unsigned char *  rgb,
unsigned char *  grey,
unsigned int  size 
)
static

Convert an RGB image to a grey scale one.

See Charles Pontyon's Colour FAQ http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html

Parameters
[in]rgb: Pointer to the 24-bits RGB bitmap.
[out]grey: Pointer to the bitmap containing the 8-bits grey data that should be allocated with a size of width * height.
[in]size: Image size corresponding to image width * height.

Definition at line 3747 of file vpImageConvert.cpp.

References RGBToGrey().

◆ RGBToGrey() [2/2]

void vpImageConvert::RGBToGrey ( unsigned char *  rgb,
unsigned char *  grey,
unsigned int  width,
unsigned int  height,
bool  flip = false 
)
static

Converts a RGB image to a grey scale one. Flips the image vertically if needed. Assumes that grey is already resized.

Note
If flip is false, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]rgb: Pointer to the 24-bits RGB bitmap.
[out]grey: Pointer to the bitmap containing the 8-bits grey data that should be allocated with a size of width * height.
[in]width,height: Image size.
[in]flip: When true, image is flipped vertically.
Examples
testColorConversion.cpp, and testConversion.cpp.

Definition at line 3765 of file vpImageConvert.cpp.

Referenced by vp1394CMUGrabber::acquire(), vpV4l2Grabber::acquire(), vp1394TwoGrabber::dequeue(), vpRealSense2::getGreyFrame(), vpSimulator::getInternalImage(), and RGBToGrey().

◆ RGBToHSV() [1/2]

void vpImageConvert::RGBToHSV ( const unsigned char *  rgb,
double *  hue,
double *  saturation,
double *  value,
unsigned int  size 
)
static

Converts an array of RGB to an array of hue, saturation, value values.

Parameters
[in]rgb: Pointer to the 24-bits RGB bitmap.
[out]hue: Array of hue values converted from RGB color space (range between [0 - 255]).
[out]saturation: Array of saturation values converted from RGB color space (range between [0 - 255]).
[out]value: Array of value values converted from RGB color space (range between [0 - 255]).
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 5004 of file vpImageConvert.cpp.

Referenced by RGBToHSV().

◆ RGBToHSV() [2/2]

void vpImageConvert::RGBToHSV ( const unsigned char *  rgb,
unsigned char *  hue,
unsigned char *  saturation,
unsigned char *  value,
unsigned int  size 
)
static

Converts an array of RGB to an array of hue, saturation, value values.

Parameters
[in]rgb: Pointer to the 24-bits RGB bitmap.
[out]hue: Array of hue values converted from RGB color space (range between [0 - 255]).
[out]saturation: Array of saturation values converted from RGB color space (range between [0 - 255]).
[out]value: Array of value values converted from RGB color space (range between [0 - 255]).
[in]size: The image size or the number of pixels corresponding to the image width * height.

Definition at line 5019 of file vpImageConvert.cpp.

References RGBToHSV().

◆ RGBToRGBa() [1/2]

void vpImageConvert::RGBToRGBa ( unsigned char *  rgb,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert RGB into RGBa.

Alpha component is set to vpRGBa::alpha_default.

Parameters
[in]rgb: Pointer to the bitmap containing the 24-bits RGB data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to image width * height.
Examples
testColorConversion.cpp.

Definition at line 3650 of file vpImageConvert.cpp.

Referenced by vp1394CMUGrabber::acquire(), vpV4l2Grabber::acquire(), vp1394TwoGrabber::acquire(), vpOccipitalStructure::acquire(), vp1394TwoGrabber::dequeue(), vpRealSense2::getColorFrame(), and vpSimulator::getInternalImage().

◆ RGBToRGBa() [2/2]

void vpImageConvert::RGBToRGBa ( unsigned char *  rgb,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height,
bool  flip = false 
)
static

Converts a RGB image to RGBa. Alpha component is set to vpRGBa::alpha_default.

Flips the image vertically if needed. Assumes that rgba is already resized.

Note
If flip is false, the SIMD lib is used to accelerate processing on x86 and ARM architecture.
Parameters
[in]rgb: Pointer to the bitmap containing the 24-bits RGB data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.
[in]flip: When true, image is flipped vertically.

Definition at line 3670 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

◆ split()

void vpImageConvert::split ( const vpImage< vpRGBa > &  src,
vpImage< unsigned char > *  pR,
vpImage< unsigned char > *  pG,
vpImage< unsigned char > *  pB,
vpImage< unsigned char > *  pa = nullptr 
)
static

Split an image from vpRGBa format to monochrome channels.

Parameters
[in]src: source image.
[out]pR: red channel. Set as nullptr if not needed.
[out]pG: green channel. Set as nullptr if not needed.
[out]pB: blue channel. Set as nullptr if not needed.
[out]pa: alpha channel. Set as nullptr if not needed.

Output channels are resized if needed.

Note
The SIMD lib is used to accelerate processing on x86 and ARM architecture.

Example code using split:

#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
int main()
{
vpImage<vpRGBa> Ic; // A color image
// Load a color image from the disk
vpImageIo::read(Ic,"image.ppm");
// Only R and B Channels are desired.
// Split Ic color image
// R and B will be resized in split function if needed
vpImageConvert::split(Ic, &R, nullptr, &B, nullptr);
// Save the the R Channel.
vpImageIo::write(R, "RChannel.pgm");
}
static void split(const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=nullptr)
Examples
grabV4l2MultiCpp11Thread.cpp, testColorConversion.cpp, testConversion.cpp, and testGaussianFilter.cpp.

Definition at line 4499 of file vpImageConvert.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getNumberOfPixel(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

Referenced by vp::clahe(), vp::equalizeHistogram(), vp::gammaCorrection(), vp::stretchContrast(), and vp::unsharpMask().

◆ YCbCrToGrey()

void vpImageConvert::YCbCrToGrey ( unsigned char *  ycbcr,
unsigned char *  grey,
unsigned int  size 
)
static

Convert an image from YCrCb 4:2:2 (Y0 Cr01 Y1 Cb01 Y2 Cr23 Y3 ...) to grey format. Destination grey image memory area has to be allocated before.

  • In YCrCb (4:2:2) format each pixel is coded using 16 bytes. Byte 0: YO (Luma for Pixel 0) Byte 1: Chroma Red Cr (Red Chroma for Pixel 0 and 1) Byte 2: Y1 (Luma for Pixel 1) Byte 3: Chroma blue Cb (Blue Chroma for Pixel 0 and 1) Byte 4: Y2 (Luma for Pixel 2)
  • In grey format, each pixel is coded using 8 bytes.
Parameters
[in]ycbcr: Pointer to the bitmap containing the YCbCr 4:2:2 data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]size: Image size corresponding to image width * height.

Definition at line 4336 of file vpImageConvert.cpp.

◆ YCbCrToRGB()

void vpImageConvert::YCbCrToRGB ( unsigned char *  ycbcr,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert an image from YCbCr 4:2:2 (Y0 Cb01 Y1 Cr01 Y2 Cb23 Y3 ...) to RGB format. Destination rgb memory area has to be allocated before.

  • In YCbCr (4:2:2) format each pixel is coded using 16 bytes. Byte 0: YO (Luma for Pixel 0) Byte 1: Chroma Blue Cb (Blue Chroma for Pixel 0 and 1) Byte 2: Y1 (Luma for Pixel 1) Byte 3: Chroma Red Cr (Red Chroma for Pixel 0 and 1) Byte 4: Y2 (Luma for Pixel 2)
  • In RGB format, each pixel is coded using 24 bytes. Byte 0: Red Byte 1: Green Byte 2: Blue
Parameters
[in]ycbcr: Pointer to the bitmap containing the YCbCr 4:2:2 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]size: Image size corresponding to image width * height.

Definition at line 4223 of file vpImageConvert.cpp.

References vpDEBUG_TRACE.

◆ YCbCrToRGBa()

void vpImageConvert::YCbCrToRGBa ( unsigned char *  ycbcr,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert an image from YCbCr 4:2:2 (Y0 Cb01 Y1 Cr01 Y2 Cb23 Y3...) to RGBa format. Destination rgba memory area has to be allocated before.

The alpha component of the converted image is set to vpRGBa::alpha_default.

  • In YCbCr (4:2:2) format each pixel is coded using 16 bytes. Byte 0: YO (Luma for Pixel 0) Byte 1: Chroma Blue Cb (Blue Chroma for Pixel 0 and 1) Byte 2: Y1 (Luma for Pixel 1) Byte 3: Chroma Red Cr (Red Chroma for Pixel 0 and 1) Byte 4: Y2 (Luma for Pixel 2)
  • In RGBa format, each pixel is coded using 24 bytes. Byte 0: Red Byte 1: Green Byte 2: Blue Byte 3: -
Parameters
[in]ycbcr: Pointer to the bitmap containing the YCbCr 4:2:2 data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to image width * height.

Definition at line 4282 of file vpImageConvert.cpp.

References vpRGBa::alpha_default, and vpDEBUG_TRACE.

◆ YCrCbToRGB()

void vpImageConvert::YCrCbToRGB ( unsigned char *  ycrcb,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert an image from YCrCb 4:2:2 (Y0 Cr01 Y1 Cb01 Y2 Cr23 Y3 ...) to RGB format. Destination rgb memory area has to be allocated before.

  • In YCrCb (4:2:2) format each pixel is coded using 16 bytes. Byte 0: YO (Luma for Pixel 0) Byte 1: Chroma Red Cr (Red Chroma for Pixel 0 and 1) Byte 2: Y1 (Luma for Pixel 1) Byte 3: Chroma blue Cb (Blue Chroma for Pixel 0 and 1) Byte 4: Y2 (Luma for Pixel 2)
  • In RGB format, each pixel is coded using 24 bytes. Byte 0: Red Byte 1: Green Byte 2: Blue
Parameters
[in]ycrcb: Pointer to the bitmap containing the YCbCr 4:2:2 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]size: Image size corresponding to image width * height.

Definition at line 4368 of file vpImageConvert.cpp.

References vpDEBUG_TRACE.

◆ YCrCbToRGBa()

void vpImageConvert::YCrCbToRGBa ( unsigned char *  ycrcb,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert an image from YCrCb 4:2:2 (Y0 Cr01 Y1 Cb01 Y2 Cr23 Y3 ...) to RGBa format. Destination rgba memory area has to be allocated before.

The alpha component of the resulting image is set to vpRGBa::alpha_default.

  • In YCrCb (4:2:2) format each pixel is coded using 16 bytes. Byte 0: YO (Luma for Pixel 0) Byte 1: Chroma Red Cr (Red Chroma for Pixel 0 and 1) Byte 2: Y1 (Luma for Pixel 1) Byte 3: Chroma blue Cb (Blue Chroma for Pixel 0 and 1) Byte 4: Y2 (Luma for Pixel 2)
  • In RGBa format, each pixel is coded using 24 bytes. Byte 0: Red Byte 1: Green Byte 2: Blue Byte 3: -
Parameters
[in]ycrcb: Pointer to the bitmap containing the YCrCb 4:2:2 data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to image width * height.

Definition at line 4426 of file vpImageConvert.cpp.

References vpRGBa::alpha_default, and vpDEBUG_TRACE.

◆ YUV411ToGrey()

void vpImageConvert::YUV411ToGrey ( unsigned char *  yuv,
unsigned char *  grey,
unsigned int  size 
)
static

Convert YUV 4:1:1 (u y1 y2 v y3 y4) into a grey image.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:1:1 data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]size: Image size corresponding to width * height.

Definition at line 1490 of file vpImageConvert.cpp.

Referenced by vp1394CMUGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ YUV411ToRGB()

void vpImageConvert::YUV411ToRGB ( unsigned char *  yuv,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert YUV 4:1:1 (u y1 y2 v y3 y4) into a RGB 24bits image.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:1:1 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]size: Image size corresponding to width * height.

Definition at line 1641 of file vpImageConvert.cpp.

References YUVToRGB().

◆ YUV411ToRGBa()

void vpImageConvert::YUV411ToRGBa ( unsigned char *  yuv,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert YUV 4:1:1 (u y1 y2 v y3 y4) images into RGBa images. The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:1:1 data.
[out]rgba: Pointer to the RGBA 32-bits bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to width * height.

Definition at line 1192 of file vpImageConvert.cpp.

References vpRGBa::alpha_default, and YUVToRGB().

Referenced by vp1394CMUGrabber::acquire(), vp1394TwoGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ YUV420ToGrey()

void vpImageConvert::YUV420ToGrey ( unsigned char *  yuv,
unsigned char *  grey,
unsigned int  size 
)
static

Convert YUV 4:2:0 [Y(NxM), U(N/2xM/2), V(N/2xM/2)] image into a grey image.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:2:0 data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]size: Image size corresponding to image width * height.

Definition at line 2140 of file vpImageConvert.cpp.

◆ YUV420ToRGB()

void vpImageConvert::YUV420ToRGB ( unsigned char *  yuv,
unsigned char *  rgb,
unsigned int  width,
unsigned int  height 
)
static

Convert YUV 4:2:0 [Y(NxM), U(N/2xM/2), V(N/2xM/2)] image into a RGB image.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:2:0 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]width,height: Image size.

Definition at line 1984 of file vpImageConvert.cpp.

◆ YUV420ToRGBa()

void vpImageConvert::YUV420ToRGBa ( unsigned char *  yuv,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height 
)
static

Convert YUV 4:2:0 [Y(NxM), U(N/2xM/2), V(N/2xM/2)] image into a RGBa image.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:2:0 data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.

Definition at line 1823 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

◆ YUV422ToGrey()

void vpImageConvert::YUV422ToGrey ( unsigned char *  yuv,
unsigned char *  grey,
unsigned int  size 
)
static

Convert YUV 4:2:2 (u01 y0 v01 y1 u23 y2 v23 y3 ...) images into a grey image. Destination grey memory area has to be allocated before.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:2:2 data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]size: Image size corresponding to width * height.
See also
YUYVToGrey()

Definition at line 1621 of file vpImageConvert.cpp.

Referenced by vp1394CMUGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ YUV422ToRGB()

void vpImageConvert::YUV422ToRGB ( unsigned char *  yuv,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert YUV 4:2:2 (u01 y0 v01 y1 u23 y2 v23 y3 ...) images into RGB images. Destination rgb memory area has to be allocated before.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:2:2 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]size: Image size corresponding to width * height.
See also
YUYVToRGB()

Definition at line 1516 of file vpImageConvert.cpp.

References YUVToRGB().

◆ YUV422ToRGBa()

void vpImageConvert::YUV422ToRGBa ( unsigned char *  yuv,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert YUV 4:2:2 (u01 y0 v01 y1 u23 y2 v23 y3 ...) images into RGBa images. Destination rgba memory area has to be allocated before.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:2:2 data.
[out]rgba: Pointer to the RGBA 32-bits bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to width * height.
See also
YUYVToRGBa()

Definition at line 1382 of file vpImageConvert.cpp.

References vpRGBa::alpha_default, and YUVToRGB().

Referenced by vp1394CMUGrabber::acquire(), vp1394TwoGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ YUV444ToGrey()

void vpImageConvert::YUV444ToGrey ( unsigned char *  yuv,
unsigned char *  grey,
unsigned int  size 
)
static

Convert YUV 4:4:4 (u y v) image into a grey image.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:4:4 data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]sizeImage size corresponding to image width * height.

Definition at line 2259 of file vpImageConvert.cpp.

Referenced by vp1394CMUGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ YUV444ToRGB()

void vpImageConvert::YUV444ToRGB ( unsigned char *  yuv,
unsigned char *  rgb,
unsigned int  size 
)
static

Convert YUV 4:4:4 (u y v) image into RGB image.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:4:4 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]sizeImage size corresponding to image width * height.

Definition at line 2208 of file vpImageConvert.cpp.

◆ YUV444ToRGBa()

void vpImageConvert::YUV444ToRGBa ( unsigned char *  yuv,
unsigned char *  rgba,
unsigned int  size 
)
static

Convert YUV 4:4:4 (u y v) image into a RGBa image.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuv: Pointer to the bitmap containing the YUV 4:4:4 data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]size: Image size corresponding to image width * height.

Definition at line 2156 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

Referenced by vp1394CMUGrabber::acquire(), vp1394TwoGrabber::acquire(), and vp1394TwoGrabber::dequeue().

◆ YUVToRGB()

static void vpImageConvert::YUVToRGB ( unsigned char  y,
unsigned char  u,
unsigned char  v,
unsigned char &  r,
unsigned char &  g,
unsigned char &  b 
)
inlinestatic

Converts a yuv pixel value in rgb format.

Parameters
yY component of a pixel.
uU component of a pixel.
vV component of a pixel.
rRed component from the YUV coding format. This value is computed using:

\[ r = 0.9999695*y - 0.0009508*(u-128) + 1.1359061*(v-128) \]

gGreen component from the YUV coding format. This value is computed using:

\[g = 0.9999695*y - 0.3959609*(u-128) - 0.5782955*(v-128) \]

bBlue component from the YUV coding format. This value is computed using:

\[b = 0.9999695*y + 2.04112*(u-128) - 0.0016314*(v-128) \]

Examples
testConversion.cpp.

Definition at line 157 of file vpImageConvert.h.

Referenced by YUV411ToRGB(), YUV411ToRGBa(), YUV422ToRGB(), and YUV422ToRGBa().

◆ YUYVToGrey()

void vpImageConvert::YUYVToGrey ( unsigned char *  yuyv,
unsigned char *  grey,
unsigned int  size 
)
static

Convert an image from YUYV 4:2:2 (y0 u01 y1 v01 y2 u23 y3 v23 ...) to grey. Destination grey memory area has to be allocated before.

Parameters
[in]yuyv: Pointer to the bitmap containing the YUYV 4:2:2 data.
[out]grey: Pointer to the 8-bits grey bitmap that should be allocated with a size of width * height.
[in]size: Image size corresponding to width * height.
See also
YUV422ToGrey()

Definition at line 1172 of file vpImageConvert.cpp.

Referenced by vpV4l2Grabber::acquire().

◆ YUYVToRGB()

void vpImageConvert::YUYVToRGB ( unsigned char *  yuyv,
unsigned char *  rgb,
unsigned int  width,
unsigned int  height 
)
static

Convert an image from YUYV 4:2:2 (y0 u01 y1 v01 y2 u23 y3 v23 ...) to RGB24. Destination rgb memory area has to be allocated before.

Parameters
[in]yuyv: Pointer to the bitmap containing the YUYV 4:2:2 data.
[out]rgb: Pointer to the RGB32 bitmap that should be allocated with a size of width * height * 3.
[in]width,height: Image size.
See also
YUV422ToRGB()

Definition at line 1120 of file vpImageConvert.cpp.

◆ YUYVToRGBa()

void vpImageConvert::YUYVToRGBa ( unsigned char *  yuyv,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height 
)
static

Convert an image from YUYV 4:2:2 (y0 u01 y1 v01 y2 u23 y3 v23 ...) to RGB32. Destination rgba memory area has to be allocated before.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuyv: Pointer to the bitmap containing the YUYV 4:2:2 data.
[out]rgba: Pointer to the RGB32 bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.
See also
YUV422ToRGBa()

Definition at line 1066 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

Referenced by vpV4l2Grabber::acquire().

◆ YV12ToRGB()

void vpImageConvert::YV12ToRGB ( unsigned char *  yuv,
unsigned char *  rgb,
unsigned int  height,
unsigned int  width 
)
static

Convert YV12 [Y(NxM), V(N/2xM/2), U(N/2xM/2)] image into RGB image.

Parameters
[in]yuv: Pointer to the bitmap containing the YV 1:2 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]width,height: Image size.

Definition at line 2439 of file vpImageConvert.cpp.

◆ YV12ToRGBa()

void vpImageConvert::YV12ToRGBa ( unsigned char *  yuv,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height 
)
static

Convert YV 1:2 [Y(NxM), V(N/2xM/2), U(N/2xM/2)] image into RGBa image.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuv: Pointer to the bitmap containing the YV 1:2 data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.

Definition at line 2278 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.

◆ YVU9ToRGB()

void vpImageConvert::YVU9ToRGB ( unsigned char *  yuv,
unsigned char *  rgb,
unsigned int  height,
unsigned int  width 
)
static

Convert YV 1:2 [Y(NxM), V(N/4xM/4), U(N/4xM/4)] image into RGB image.

Parameters
[in]yuv: Pointer to the bitmap containing the YV 1:2 data.
[out]rgb: Pointer to the 24-bits RGB bitmap that should be allocated with a size of width * height * 3.
[in]width,height: Image size.

Definition at line 3131 of file vpImageConvert.cpp.

◆ YVU9ToRGBa()

void vpImageConvert::YVU9ToRGBa ( unsigned char *  yuv,
unsigned char *  rgba,
unsigned int  width,
unsigned int  height 
)
static

Convert YVU 9 [Y(NxM), V(N/4xM/4), U(N/4xM/4)] image into a RGBa image.

The alpha component of the converted image is set to vpRGBa::alpha_default.

Parameters
[in]yuv: Pointer to the bitmap containing the YVU 9 data.
[out]rgba: Pointer to the 32-bits RGBA bitmap that should be allocated with a size of width * height * 4.
[in]width,height: Image size.

Definition at line 2598 of file vpImageConvert.cpp.

References vpRGBa::alpha_default.