Visual Servoing Platform
version 3.2.0 under development (2019-01-22)
|
#include <visp3/core/vpImageTools.h>
Public Types | |
enum | vpImageInterpolationType { INTERPOLATION_NEAREST, INTERPOLATION_LINEAR, INTERPOLATION_CUBIC } |
Public Member Functions | |
template<class Type > | |
void | createSubImage (const vpImage< Type > &I, unsigned int roi_top, unsigned int roi_left, unsigned int roi_height, unsigned int roi_width, vpImage< Type > &crop) |
template<class Type > | |
void | createSubImage (const vpImage< Type > &I, const vpRect &roi, vpImage< Type > &crop) |
template<> | |
void | binarise (vpImage< unsigned char > &I, unsigned char threshold1, unsigned char threshold2, unsigned char value1, unsigned char value2, unsigned char value3, const bool useLUT) |
template<> | |
void | resizeBicubic (const vpImage< vpRGBa > &I, vpImage< vpRGBa > &Ires, const unsigned int i, const unsigned int j, const float u, const float v, const float xFrac, const float yFrac) |
template<> | |
void | resizeBilinear (const vpImage< vpRGBa > &I, vpImage< vpRGBa > &Ires, const unsigned int i, const unsigned int j, const float u, const float v, const float xFrac, const float yFrac) |
Static Public Member Functions | |
template<class Type > | |
static void | binarise (vpImage< Type > &I, Type threshold1, Type threshold2, Type value1, Type value2, Type value3, const bool useLUT=true) |
static void | changeLUT (vpImage< unsigned char > &I, unsigned char A, unsigned char newA, unsigned char B, unsigned char newB) |
template<class Type > | |
static void | crop (const vpImage< Type > &I, double roi_top, double roi_left, unsigned int roi_height, unsigned int roi_width, vpImage< Type > &crop, unsigned int v_scale=1, unsigned int h_scale=1) |
static void | columnMean (const vpImage< double > &I, vpRowVector &result) |
template<class Type > | |
static void | crop (const vpImage< Type > &I, const vpImagePoint &topLeft, unsigned int roi_height, unsigned int roi_width, vpImage< Type > &crop, unsigned int v_scale=1, unsigned int h_scale=1) |
template<class Type > | |
static void | crop (const vpImage< Type > &I, const vpRect &roi, vpImage< Type > &crop, unsigned int v_scale=1, unsigned int h_scale=1) |
template<class Type > | |
static void | crop (const unsigned char *bitmap, unsigned int width, unsigned int height, const vpRect &roi, vpImage< Type > &crop, unsigned int v_scale=1, unsigned int h_scale=1) |
static void | extract (const vpImage< unsigned char > &Src, vpImage< unsigned char > &Dst, const vpRectOriented &r) |
static void | extract (const vpImage< unsigned char > &Src, vpImage< double > &Dst, const vpRectOriented &r) |
template<class Type > | |
static void | flip (const vpImage< Type > &I, vpImage< Type > &newI) |
template<class Type > | |
static void | flip (vpImage< Type > &I) |
static void | imageDifference (const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, vpImage< unsigned char > &Idiff) |
static void | imageDifference (const vpImage< vpRGBa > &I1, const vpImage< vpRGBa > &I2, vpImage< vpRGBa > &Idiff) |
static void | imageDifferenceAbsolute (const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, vpImage< unsigned char > &Idiff) |
static void | imageDifferenceAbsolute (const vpImage< double > &I1, const vpImage< double > &I2, vpImage< double > &Idiff) |
static void | imageDifferenceAbsolute (const vpImage< vpRGBa > &I1, const vpImage< vpRGBa > &I2, vpImage< vpRGBa > &Idiff) |
static void | imageAdd (const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, vpImage< unsigned char > &Ires, const bool saturate=false) |
static void | imageSubtract (const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, vpImage< unsigned char > &Ires, const bool saturate=false) |
static void | initUndistortMap (const vpCameraParameters &cam, unsigned int width, unsigned int height, vpArray2D< int > &mapU, vpArray2D< int > &mapV, vpArray2D< float > &mapDu, vpArray2D< float > &mapDv) |
static double | interpolate (const vpImage< unsigned char > &I, const vpImagePoint &point, const vpImageInterpolationType &method=INTERPOLATION_NEAREST) |
static void | integralImage (const vpImage< unsigned char > &I, vpImage< double > &II, vpImage< double > &IIsq) |
static double | normalizedCorrelation (const vpImage< double > &I1, const vpImage< double > &I2, const bool useOptimized=true) |
static void | normalize (vpImage< double > &I) |
static void | remap (const vpImage< unsigned char > &I, const vpArray2D< int > &mapU, const vpArray2D< int > &mapV, const vpArray2D< float > &mapDu, const vpArray2D< float > &mapDv, vpImage< unsigned char > &Iundist) |
static void | remap (const vpImage< vpRGBa > &I, const vpArray2D< int > &mapU, const vpArray2D< int > &mapV, const vpArray2D< float > &mapDu, const vpArray2D< float > &mapDv, vpImage< vpRGBa > &Iundist) |
template<class Type > | |
static void | resize (const vpImage< Type > &I, vpImage< Type > &Ires, const unsigned int width, const unsigned int height, const vpImageInterpolationType &method=INTERPOLATION_NEAREST) |
template<class Type > | |
static void | resize (const vpImage< Type > &I, vpImage< Type > &Ires, const vpImageInterpolationType &method=INTERPOLATION_NEAREST) |
static void | templateMatching (const vpImage< unsigned char > &I, const vpImage< unsigned char > &I_tpl, vpImage< double > &I_score, const unsigned int step_u, const unsigned int step_v, const bool useOptimized=true) |
template<class Type > | |
static void | undistort (const vpImage< Type > &I, const vpCameraParameters &cam, vpImage< Type > &newI, unsigned int nThreads=2) |
Deprecated functions | |
template<class Type > | |
static vp_deprecated void | createSubImage (const vpImage< Type > &I, unsigned int i_sub, unsigned int j_sub, unsigned int nrow_sub, unsigned int ncol_sub, vpImage< Type > &S) |
template<class Type > | |
static vp_deprecated void | createSubImage (const vpImage< Type > &I, const vpRect &rect, vpImage< Type > &S) |
Various image tools; sub-image extraction, modification of the look up table, binarisation...
Definition at line 76 of file vpImageTools.h.
Enumerator | |
---|---|
INTERPOLATION_NEAREST |
Nearest neighbor interpolation (fastest). |
INTERPOLATION_LINEAR |
Bi-linear interpolation. |
INTERPOLATION_CUBIC |
Bi-cubic interpolation. |
Definition at line 79 of file vpImageTools.h.
|
inlinestatic |
Binarise an image.
Definition at line 430 of file vpImageTools.h.
References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().
Referenced by vp::autoThreshold().
|
inline |
Binarise an image.
Definition at line 464 of file vpImageTools.h.
References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::performLut().
|
static |
Change the look up table (LUT) of an image. Considering pixel gray level values in the range , this method allows to rescale these values in by linear interpolation:
I | : Image to process. |
A | : Low gray level value of the range to consider. |
A_star | : New gray level value to attribute to pixel who's value was A |
B | : Height gray level value of the range to consider. |
B_star | : New gray level value to attribute to pixel who's value was B |
vpImageException::incorrectInitializationError | If . |
As shown in the example below, this method can be used to binarize an image. For an unsigned char image (in the range 0-255), thresholding this image at level 127 can be done by:
Definition at line 113 of file vpImageTools.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpImageException::incorrectInitializationError, and vpERROR_TRACE.
|
static |
Compute the column-wise mean intensities.
I | : The image. |
V | : The result vector. |
Definition at line 631 of file vpImageTools.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpRowVector::resize().
|
static |
|
static |
void vpImageTools::createSubImage | ( | const vpImage< Type > & | I, |
unsigned int | roi_top, | ||
unsigned int | roi_left, | ||
unsigned int | roi_height, | ||
unsigned int | roi_width, | ||
vpImage< Type > & | crop | ||
) |
Crop a region of interest (ROI) in an image.
I | : Input image from which a sub image will be extracted. |
roi_top | : ROI vertical position of the upper/left corner in the input image. |
roi_left | : ROI horizontal position of the upper/left corner in the input image. |
roi_height | : Cropped image height corresponding to the ROI height. |
roi_width | : Cropped image width corresponding to the ROI height. |
crop | : Cropped image. |
Definition at line 224 of file vpImageTools.h.
References crop().
void vpImageTools::createSubImage | ( | const vpImage< Type > & | I, |
const vpRect & | roi, | ||
vpImage< Type > & | crop | ||
) |
Crop an image region of interest.
I | : Input image from which a sub image will be extracted. |
roi | : Region of interest in image I corresponding to the cropped part of the image. |
crop | : Cropped image. |
Definition at line 245 of file vpImageTools.h.
References crop().
|
static |
Crop a region of interest (ROI) in an image. The ROI coordinates and dimension are defined in the original image.
Setting v_scale and h_scale to values different from 1 allows also to subsample the cropped image.
I | : Input image from which a sub image will be extracted. |
roi_top | : ROI vertical position of the upper/left corner in the input image. |
roi_left | : ROI horizontal position of the upper/left corner in the input image. |
roi_height | : Cropped image height corresponding to the ROI height. |
roi_width | : Cropped image width corresponding to the ROI height. |
crop | : Cropped image. |
v_scale | [in] : Vertical subsampling factor applied to the ROI. |
h_scale | [in] : Horizontal subsampling factor applied to the ROI. |
Definition at line 272 of file vpImageTools.h.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
Referenced by vpV4l2Grabber::acquire(), createSubImage(), crop(), vpDisplayGTK::displayImageROI(), vpMeNurbs::seekExtremitiesCanny(), and templateMatching().
|
static |
Crop a region of interest (ROI) in an image. The ROI coordinates and dimension are defined in the original image.
Setting v_scale and h_scale to values different from 1 allows also to subsample the cropped image.
I | : Input image from which a sub image will be extracted. |
topLeft | : ROI position of the upper/left corner in the input image. |
roi_height | : Cropped image height corresponding to the ROI height. |
roi_width | : Cropped image width corresponding to the ROI height. |
crop | : Cropped image. |
v_scale | [in] : Vertical subsampling factor applied to the ROI. |
h_scale | [in] : Horizontal subsampling factor applied to the ROI. |
Definition at line 328 of file vpImageTools.h.
References crop(), vpImagePoint::get_i(), and vpImagePoint::get_j().
|
static |
Crop a region of interest (ROI) in an image. The ROI coordinates and dimension are defined in the original image.
Setting v_scale and h_scale to values different from 1 allows also to subsample the cropped image.
I | : Input image from which a sub image will be extracted. |
roi | : Region of interest in image I corresponding to the cropped part of the image. |
crop | : Cropped image. |
v_scale | [in] : Vertical subsampling factor applied to the ROI. |
h_scale | [in] : Horizontal subsampling factor applied to the ROI. |
Definition at line 352 of file vpImageTools.h.
References crop(), vpRect::getHeight(), vpRect::getLeft(), vpRect::getTop(), and vpRect::getWidth().
|
static |
Crop a region of interest (ROI) in an image. The ROI coordinates and dimension are defined in the original image.
Setting v_scale and h_scale to values different from 1 allows also to subsample the cropped image.
bitmap | : Pointer to the input image from which a sub image will be extracted. |
width,height | : Size of the input image. |
roi | : Region of interest corresponding to the cropped part of the image. |
crop | : Cropped image. |
v_scale | [in] : Vertical subsampling factor applied to the ROI. |
h_scale | [in] : Horizontal subsampling factor applied to the ROI. |
Definition at line 377 of file vpImageTools.h.
References vpRect::getHeight(), vpRect::getLeft(), vpRect::getTop(), vpRect::getWidth(), and vpImage< Type >::resize().
|
static |
Extract a rectangular region from an image.
Src | : The source image. |
Dst | : The resulting image. |
r | : The rectangle area. |
Definition at line 701 of file vpImageTools.cpp.
References vpImagePoint::get_i(), vpImagePoint::get_j(), vpRectOriented::getHeight(), vpRectOriented::getOrientation(), vpRectOriented::getTopLeft(), vpRectOriented::getWidth(), interpolate(), INTERPOLATION_LINEAR, vpImage< Type >::resize(), and vpMath::round().
|
static |
Extract a rectangular region from an image.
Src | : The source image. |
Dst | : The resulting image. |
r | : The rectangle area. |
Definition at line 724 of file vpImageTools.cpp.
References vpImagePoint::get_i(), vpImagePoint::get_j(), vpRectOriented::getHeight(), vpRectOriented::getOrientation(), vpRectOriented::getTopLeft(), vpRectOriented::getWidth(), interpolate(), INTERPOLATION_LINEAR, vpImage< Type >::resize(), and vpMath::round().
|
static |
Flip vertically the input image and give the result in the output image.
I | : Input image to flip. |
newI | : Output image which is the flipped input image. |
Definition at line 785 of file vpImageTools.h.
References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
|
static |
Flip vertically the input image.
I | : Input image which is flipped and modified in output. |
The following example shows how to use this function:
Definition at line 829 of file vpImageTools.h.
References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
|
static |
Compute the image addition: .
I1 | : The first image. |
I2 | : The second image. |
Ires | : |
saturate | : If true, saturate the result to [0 ; 255] using vpMath::saturate, otherwise overflow may occur. |
Definition at line 378 of file vpImageTools.cpp.
References vpImage< Type >::bitmap, vpCPUFeatures::checkSSE2(), vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
Referenced by vp::fillHoles().
|
static |
Compute the signed difference between the two images I1 and I2 for visualization issue : Idiff = I1-I2
I1 | : The first image. |
I2 | : The second image. |
Idiff | : The result of the difference. |
Definition at line 150 of file vpImageTools.cpp.
References vpImage< Type >::bitmap, vpCPUFeatures::checkSSSE3(), vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), vpMath::maximum(), vpMath::minimum(), and vpImage< Type >::resize().
|
static |
Compute the signed difference between the two images I1 and I2 RGB components for visualization issue : Idiff = I1-I2. The fourth component named A is not compared. It is set to 0 in the resulting difference image.
I1 | : The first image. |
I2 | : The second image. |
Idiff | : The result of the difference between RGB components. |
Definition at line 220 of file vpImageTools.cpp.
References vpRGBa::A, vpRGBa::B, vpImage< Type >::bitmap, vpCPUFeatures::checkSSSE3(), vpException::dimensionError, vpRGBa::G, vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), vpMath::maximum(), vpMath::minimum(), vpRGBa::R, and vpImage< Type >::resize().
|
static |
Compute the difference between the two images I1 and I2
I1 | : The first image. |
I2 | : The second image. |
Idiff | : The result of the difference. |
Definition at line 294 of file vpImageTools.cpp.
References vpMath::abs(), vpImage< Type >::bitmap, vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
|
static |
Compute the difference between the two images I1 and I2.
I1 | : The first image. |
I2 | : The second image. |
Idiff | : The result of the difference. |
Definition at line 318 of file vpImageTools.cpp.
References vpMath::abs(), vpImage< Type >::bitmap, vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
|
static |
Compute the difference between the two images I1 and I2 RGB components. The fourth component named A is not compared. It is set to 0 in the resulting difference image.
I1 | : The first image. |
I2 | : The second image. |
Idiff | : The result of the difference between RGB components. |
Definition at line 346 of file vpImageTools.cpp.
References vpRGBa::A, vpMath::abs(), vpRGBa::B, vpImage< Type >::bitmap, vpException::dimensionError, vpRGBa::G, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpRGBa::R, and vpImage< Type >::resize().
|
static |
Compute the image addition: .
I1 | : The first image. |
I2 | : The second image. |
Ires | : |
saturate | : If true, saturate the result to [0 ; 255] using vpMath::saturate, otherwise overflow may occur. |
Definition at line 420 of file vpImageTools.cpp.
References vpImage< Type >::bitmap, vpCPUFeatures::checkSSE2(), vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
Referenced by vp::fillHoles().
|
static |
Compute the undistortion transformation map.
cam | : Camera intrinsic parameters with distortion coefficients. |
width | : Image width. |
height | : Image height. |
mapU | : 2D array that contains at each coordinate the u-coordinate in the distorted image. |
mapV | : 2D array that contains at each coordinate the v-coordinate in the distorted image. |
mapDu | : 2D array that contains at each coordinate the for the interpolation. |
mapDv | : 2D array that contains at each coordinate the for the interpolation. |
Definition at line 466 of file vpImageTools.cpp.
References vpCameraParameters::get_kud(), vpCameraParameters::get_px(), vpCameraParameters::get_py(), vpCameraParameters::get_u0(), vpCameraParameters::get_v0(), and vpArray2D< Type >::resize().
|
static |
Compute the integral images:
.
I | : Input image. |
II | : Integral image II. |
IIsq | : Integral image IIsq. |
Definition at line 536 of file vpImageTools.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), vpImage< Type >::resize(), and vpMath::sqr().
Referenced by templateMatching().
|
static |
Get the interpolated value at a given location.
I | : The image to perform intepolation in. |
point | : The image point. |
method | : The interpolation method (only interpolation with vpImageTools::INTERPOLATION_NEAREST and vpImageTools::INTERPOLATION_LINEAR are implemented). |
Definition at line 662 of file vpImageTools.cpp.
References vpImagePoint::get_i(), vpImagePoint::get_j(), INTERPOLATION_CUBIC, INTERPOLATION_LINEAR, INTERPOLATION_NEAREST, vpException::notImplementedError, and vpMath::round().
Referenced by extract().
|
static |
Normalize the image intensities.
I | : The image to normalize. |
Definition at line 647 of file vpImageTools.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getSum(), and vpImage< Type >::getWidth().
|
static |
Compute a correlation between 2 images.
I1 | : The first image. |
I2 | : The second image. |
useOptimized | : Use SSE if true and available. |
Definition at line 561 of file vpImageTools.cpp.
References vpImage< Type >::bitmap, vpCPUFeatures::checkSSE2(), vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getMeanValue(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), and vpMath::sqr().
Referenced by templateMatching().
|
static |
Apply the transformation map to the image.
I | : Input grayscale image. |
mapU | : Map that contains at each destination coordinate the u-coordinate in the source image. |
mapV | : Map that contains at each destination coordinate the v-coordinate in the source image. |
mapDu | : Map that contains at each destination coordinate the for the interpolation. |
mapDv | : Map that contains at each destination coordinate the for the interpolation. |
Iundist | : Output transformed grayscale image. |
Definition at line 926 of file vpImageTools.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
|
static |
Apply the transformation map to the image.
I | : Input color image. |
mapU | : Map that contains at each destination coordinate the u-coordinate in the source image. |
mapV | : Map that contains at each destination coordinate the v-coordinate in the source image. |
mapDu | : Map that contains at each destination coordinate the for the interpolation. |
mapDv | : Map that contains at each destination coordinate the for the interpolation. |
Iundist | : Output transformed color image. |
Definition at line 969 of file vpImageTools.cpp.
References vpCPUFeatures::checkSSE2(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
|
static |
Resize the image using one interpolation method (by default it uses the nearest neighbor interpolation).
I | : Input image. |
Ires | : Output image resized to width, height. |
width | : Resized width. |
height | : Resized height. |
method | : Interpolation method. |
Definition at line 1030 of file vpImageTools.h.
References vpImage< Type >::resize().
|
static |
Resize the image using one interpolation method (by default it uses the nearest neighbor interpolation).
I | : Input image. |
Ires | : Output image resized (you have to init the image Ires at the desired size). |
method | : Interpolation method. |
Definition at line 1049 of file vpImageTools.h.
References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().
|
inline |
Definition at line 907 of file vpImageTools.h.
References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().
|
inline |
Definition at line 983 of file vpImageTools.h.
References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().
|
static |
Match a template image into another image using zero-mean normalized cross-correlation:
I | : Input image. |
I_tpl | : Template image. |
I_score | : Output template matching score. |
step_u | : Step in u-direction to speed-up the computation. |
step_v | : Step in v-direction to speed-up the computation. |
useOptimized | : Use optimized version (SSE, OpenMP, integral images, ...) if true and available. |
Definition at line 754 of file vpImageTools.cpp.
References vpImage< Type >::bitmap, vpCPUFeatures::checkSSE2(), vpImageConvert::convert(), crop(), vpImage< Type >::getHeight(), vpImage< Type >::getSize(), vpImage< Type >::getWidth(), integralImage(), normalizedCorrelation(), vpImage< Type >::resize(), and vpMath::sqr().
|
static |
Undistort an image
I | : Input image to undistort. |
cam | : Parameters of the camera causing distortion. |
undistI | : Undistorted output image. The size of this image will be the same than the input image I. If the distortion parameter is null (see cam.get_kd_mp()), undistI is just a copy of I. |
nThreads | : Number of threads to use if pthreads library is available. |
vpImageTools::initUndistortMap()
once and then vpImageTools::remap()
to undistort the images. This will be less time consuming.Definition at line 621 of file vpImageTools.h.
References vpImage< Type >::bitmap, vpCameraParameters::get_kud(), vpCameraParameters::get_px(), vpCameraParameters::get_py(), vpCameraParameters::get_u0(), vpCameraParameters::get_v0(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpImage< Type >::resize(), and vpMath::sqr().