ImageConvert¶
- class ImageConvert¶
Bases:
pybind11_object
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/vpConfig.h> #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) #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME ; #endif 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); vpImage<unsigned char> I; vpImageConvert::convert (A, I); #ifdef VISP_HAVE_PNG vpImageIo::write (I, "monkey.png"); // Gray #endif } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } #endif }
Methods
See C++ documentation of the function for more info
See C++ documentation of the function for more info
See C++ documentation of the function for more info
See C++ documentation of the function for more info
Overloaded function.
Overloaded function.
See C++ documentation of the function for more info
See C++ documentation of the function for more info
See C++ documentation of the function for more info
Overloaded function.
See C++ documentation of the function for more info
See C++ documentation of the function for more info
Overloaded function.
See C++ documentation of the function for more info
See C++ documentation of the function for more info
See C++ documentation of the function for more info
See C++ documentation of the function for more info
Converts a yuv pixel value in rgb format.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Inherited Methods
Operators
__doc__
__module__
Attributes
__annotations__
- static BGRToRGBa(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8], flip: bool = False) None ¶
See C++ documentation of the function for more info
- static BGRaToRGBa(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8], flip: bool = False) None ¶
See C++ documentation of the function for more info
- static GreyToRGB(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static GreyToRGBa(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static HSVToRGB(*args, **kwargs)¶
Overloaded function.
HSVToRGB(hsv: numpy.ndarray[numpy.uint8], rgb: numpy.ndarray[numpy.uint8], h_full: bool = True) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
HSVToRGB(hsv: numpy.ndarray[numpy.float64], rgb: numpy.ndarray[numpy.uint8]) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
- static HSVToRGBa(*args, **kwargs)¶
Overloaded function.
HSVToRGBa(hsv: numpy.ndarray[numpy.uint8], rgb: numpy.ndarray[numpy.uint8], h_full: bool = True) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
HSVToRGBa(hsv: numpy.ndarray[numpy.float64], rgb: numpy.ndarray[numpy.uint8]) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
- static MONO16ToGrey(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static MONO16ToRGBa(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static RGBToGrey(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static RGBToHSV(*args, **kwargs)¶
Overloaded function.
RGBToHSV(rgb: numpy.ndarray[numpy.uint8], hsv: numpy.ndarray[numpy.uint8], h_full: bool = True) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
RGBToHSV(rgb: numpy.ndarray[numpy.uint8], hsv: numpy.ndarray[numpy.float64]) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
- static RGBToRGBa(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static RGBaToGrey(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static RGBaToHSV(*args, **kwargs)¶
Overloaded function.
RGBaToHSV(rgb: numpy.ndarray[numpy.uint8], hsv: numpy.ndarray[numpy.uint8], h_full: bool = True) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
RGBaToHSV(rgb: numpy.ndarray[numpy.uint8], hsv: numpy.ndarray[numpy.float64]) -> None
Convert from HSV Planes (as a 3 x H x W array) to a an RGB/RGBA array (as an H x W x 3 or H x W x 4 array)
- static RGBaToRGB(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static YUV444ToGrey(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static YUV444ToRGB(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static YUV444ToRGBa(src: numpy.ndarray[numpy.uint8], dest: numpy.ndarray[numpy.uint8]) None ¶
See C++ documentation of the function for more info
- static YUVToRGB(y: int, u: int, v: int, r: int, g: int, b: int) None ¶
Converts a yuv pixel value in rgb format.
- Parameters:
- y: int¶
Y component of a pixel.
- u: int¶
U component of a pixel.
- v: int¶
V component of a pixel.
- r: int¶
Red component from the YUV coding format. This value is computed using:
\[r = 0.9999695*y - 0.0009508*(u-128) + 1.1359061*(v-128)\]- g: int¶
Green component from the YUV coding format. This value is computed using:
\[g = 0.9999695*y - 0.3959609*(u-128) - 0.5782955*(v-128)\]- b: int¶
Blue component from the YUV coding format. This value is computed using:
\[b = 0.9999695*y + 2.04112*(u-128) - 0.0016314*(v-128)\]
- __init__(*args, **kwargs)¶
- static convert(*args, **kwargs)¶
Overloaded function.
convert(src: visp._visp.core.ImageGray, dest: visp._visp.core.ImageRGBa) -> None
Convert a vpImage <unsigned char> to a vpImage < vpRGBa >. Tha alpha component is set to vpRGBa::alpha_default .
Note
See GreyToRGBa()
- Parameters:
- src
Source image
- dest
Destination image.
convert(src: visp._visp.core.ImageRGBa, dest: visp._visp.core.ImageGray, nThreads: int = 0) -> None
Convert a vpImage <unsigned char> to a vpImage < vpRGBa >
Note
See RGBaToGrey()
- Parameters:
- src
Source image
- dest
Destination image.
- nThreads
Number of threads to use if OpenMP is available. If 0 is passed, OpenMP will choose the number of threads.
convert(src: visp._visp.core.ImageFloat, dest: visp._visp.core.ImageGray) -> None
Convert a vpImage <float> to a vpImage <unsigned char> by renormalizing between 0 and 255.
- Parameters:
- src
Source image
- dest
Destination image.
convert(src: visp._visp.core.ImageRGBf, dest: visp._visp.core.ImageRGBa) -> None
Convert a vpImage < vpRGBf > to a vpImage <unsigned char> by renormalizing between 0 and 255.
- Parameters:
- src
Source image
- dest
Destination image.
convert(src: visp._visp.core.ImageGray, dest: visp._visp.core.ImageFloat) -> None
Convert a vpImage <unsigned char> to a vpImage <float> by basic casting.
- Parameters:
- src
Source image
- dest
Destination image.
convert(src: visp._visp.core.ImageDouble, dest: visp._visp.core.ImageGray) -> None
Convert a vpImage <double> to a vpImage <unsigned char> by renormalizing between 0 and 255.
- Parameters:
- src
Source image
- dest
Destination image.
convert(src: visp._visp.core.ImageGray, dest: visp._visp.core.ImageDouble) -> None
Convert a vpImage <unsigned char> to a vpImage <double> by basic casting.
- Parameters:
- src
Source image
- dest
Destination image.
convert(src: visp._visp.core.ImageUInt16, dest: visp._visp.core.ImageGray, bitshift: int) -> None
Convert a vpImage <uint16_t> to a vpImage <unsigned char>.
- Parameters:
- src
Source image
- dest
Destination image.
- bitshift
Right bit shift applied to each source element.
convert(src: visp._visp.core.ImageGray, dest: visp._visp.core.ImageUInt16, bitshift: int) -> None
Convert a vpImage <unsigned char> to a vpImage <uint16_t>.
- Parameters:
- src
Source image
- dest
Destination image.
- bitshift
Left bit shift applied to each source element.
convert(src: cv::Mat, dest: visp._visp.core.ImageRGBa, flip: bool = false) -> None
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.
Warning
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).
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageConvert.h> #include <visp3/core/vpRGBa.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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> vpImageConvert::convert(Ip, Ic); // ... #endif }
- Parameters:
- src
Source image in OpenCV format.
- dest
Destination image in ViSP format.
- flip
Set to true to vertically flip the converted image.
convert(src: cv::Mat, dest: visp._visp.core.ImageGray, flip: bool = false, nThreads: int = 0) -> None
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.
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageConvert.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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> vpImageConvert::convert(Ip, Ig); // ... #endif }
- Parameters:
- src
Source image in OpenCV format.
- dest
Destination image in ViSP format.
- flip
Set to true to vertically flip the converted image.
- nThreads
number of threads to use if OpenMP is available. If 0 is passed, OpenMP will choose the number of threads.
convert(src: cv::Mat, dest: visp._visp.core.ImageFloat, flip: bool = false) -> None
Converts cv::Mat CV_32FC1 / CV_16SC1 format to ViSP vpImage<float> .
- Parameters:
- src
OpenCV image in CV_32FC1 / CV_16SC1 format.
- dest
ViSP image in float format.
- flip
When true during conversion flip image vertically.
convert(src: cv::Mat, dest: visp._visp.core.ImageDouble, flip: bool = false) -> None
Converts cv::Mat CV_32FC1 format to ViSP vpImage<double> .
- Parameters:
- src
OpenCV image in CV_32FC1 format.
- dest
ViSP image in double format.
- flip
When true during conversion flip image vertically.
convert(src: cv::Mat, dest: visp._visp.core.ImageRGBf, flip: bool = false) -> None
Converts cv::Mat CV_32FC3 format to ViSP vpImage<vpRGBf>.
- Parameters:
- src
OpenCV image in CV_32FC3 format.
- dest
ViSP image in vpRGBf format.
- flip
When true during conversion flip image vertically.
convert(src: cv::Mat, dest: visp._visp.core.ImageUInt16, flip: bool = false) -> None
Converts cv::Mat CV_16UC1 format to ViSP vpImage<uint16_t>.
- Parameters:
- src
OpenCV image in CV_16UC1 format.
- dest
ViSP image in uint16_t format.
- flip
When true during conversion flip image vertically.
convert(src: visp._visp.core.ImageRGBa, dest: cv::Mat) -> None
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.
#include <visp3/core/vpImageConvert.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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. vpImageConvert::convert(I, Icv); // Treatments on cv::Mat Icv //... // Save the cv::Mat on the disk cv::imwrite("image-cv.ppm", Icv); #endif }
- Parameters:
- src
Source image ( vpRGBa format).
- dest
Destination image (BGR format).
convert(src: visp._visp.core.ImageGray, dest: cv::Mat, copyData: bool = true) -> None
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.
#include <visp3/core/vpImageConvert.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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 vpImageConvert::convert(Ig, Ip); // Treatments on cv::Mat Ip //... // Save the cv::Mat on the disk cv::imwrite("image-cv.pgm", Ip); #endif }
- Parameters:
- src
Source image.
- dest
Destination image.
- copyData
If true, the image is copied and modification in one object will not modified the other.
convert(src: visp._visp.core.ImageFloat, dest: cv::Mat, copyData: bool = true) -> None
convert(src: visp._visp.core.ImageDouble, dest: cv::Mat, copyData: bool = true) -> None
convert(src: visp._visp.core.ImageRGBf, dest: cv::Mat) -> None
- static createDepthHistogram(*args, **kwargs)¶
Overloaded function.
createDepthHistogram(src_depth: visp._visp.core.ImageUInt16, dest_rgba: visp._visp.core.ImageRGBa) -> None
Convert the input 16-bits depth image to a color depth image. The input depth value is assigned a color value proportional to its frequency. Tha alpha component of the resulting image is set to vpRGBa::alpha_default .
- Parameters:
- src_depth
Input 16-bits depth image.
- dest_rgba
Output color depth image.
createDepthHistogram(src_depth: visp._visp.core.ImageUInt16, dest_depth: visp._visp.core.ImageGray) -> None
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:
- src_depth
Input 16-bits depth image.
- dest_depth
Output grayscale depth image.
createDepthHistogram(src_depth: visp._visp.core.ImageFloat, dest_depth: visp._visp.core.ImageRGBa) -> None
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:
- src_depth
Input float depth image.
createDepthHistogram(src_depth: visp._visp.core.ImageFloat, dest_depth: visp._visp.core.ImageGray) -> None
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:
- src_depth
Input float depth image.
- dest_depth
Output grayscale depth image.
- static demosaicBGGRToRGBaBilinear(*args, **kwargs)¶
Overloaded function.
demosaicBGGRToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicBGGRToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicBGGRToRGBaMalvar(*args, **kwargs)¶
Overloaded function.
demosaicBGGRToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicBGGRToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicGBRGToRGBaBilinear(*args, **kwargs)¶
Overloaded function.
demosaicGBRGToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicGBRGToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicGBRGToRGBaMalvar(*args, **kwargs)¶
Overloaded function.
demosaicGBRGToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicGBRGToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicGRBGToRGBaBilinear(*args, **kwargs)¶
Overloaded function.
demosaicGRBGToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicGRBGToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicGRBGToRGBaMalvar(*args, **kwargs)¶
Overloaded function.
demosaicGRBGToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicGRBGToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicRGGBToRGBaBilinear(*args, **kwargs)¶
Overloaded function.
demosaicRGGBToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicRGGBToRGBaBilinear(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
- static demosaicRGGBToRGBaMalvar(*args, **kwargs)¶
Overloaded function.
demosaicRGGBToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint8], rgba: numpy.ndarray[numpy.uint8], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.
demosaicRGGBToRGBaMalvar(bayer_data: numpy.ndarray[numpy.uint16], rgba: numpy.ndarray[numpy.uint16], num_threads: int = 0) -> None
Demosaic function implementation, see C++ documentation.