ImageTools

class ImageTools

Bases: pybind11_object

Various image tools; sub-image extraction, modification of the look up table, binarisation…

Methods

__init__

changeLUT

Change the look up table (LUT) of an image.

columnMean

Compute the column-wise mean intensities.

crop

Overloaded function.

extract

Overloaded function.

imageAdd

Compute the image addition: \(Ires = I1 + I2\) .

imageDifference

Overloaded function.

imageDifferenceAbsolute

Overloaded function.

imageSubtract

Compute the image addition: \(Ires = I1 - I2\) .

inMask

Overloaded function.

initUndistortMap

Compute the undistortion transformation map.

integralImage

Compute the integral images:

interpolate

normalize

Normalize the image intensities.

normalizedCorrelation

Compute a correlation between 2 images.

remap

Overloaded function.

templateMatching

Match a template image into another image using zero-mean normalized cross-correlation:

warpImage

Overloaded function.

Inherited Methods

Operators

__doc__

__init__

__module__

Attributes

INTERPOLATION_AREA

INTERPOLATION_CUBIC

INTERPOLATION_LINEAR

INTERPOLATION_NEAREST

__annotations__

class ImageInterpolationType(self, value: int)

Bases: pybind11_object

Values:

  • INTERPOLATION_NEAREST: Nearest neighbor interpolation.

  • INTERPOLATION_LINEAR: Bi-linear interpolation (optimized by SIMD lib if enabled).

  • INTERPOLATION_CUBIC: Bi-cubic interpolation.

  • INTERPOLATION_AREA: Area interpolation (optimized by SIMD lib if enabled).

__and__(self, other: object) object
__eq__(self, other: object) bool
__ge__(self, other: object) bool
__getstate__(self) int
__gt__(self, other: object) bool
__hash__(self) int
__index__(self) int
__init__(self, value: int)
__int__(self) int
__invert__(self) object
__le__(self, other: object) bool
__lt__(self, other: object) bool
__ne__(self, other: object) bool
__or__(self, other: object) object
__rand__(self, other: object) object
__ror__(self, other: object) object
__rxor__(self, other: object) object
__setstate__(self, state: int) None
__xor__(self, other: object) object
property name : str
__init__(*args, **kwargs)
static changeLUT(I: visp._visp.core.ImageGray, A: int, newA: int, B: int, newB: int) None

Change the look up table (LUT) of an image. Considering pixel gray level values \(l\) in the range \([A, B]\) , this method allows to rescale these values in \([A^*, B^*]\) by linear interpolation:

\(\left\{ \begin{array}{ll} l \in ]-\infty, A] \mbox{, } & l = A^* \\l \in [B, \infty[ \mbox{, } & l = B^* \\l \in ]A, B[ \mbox{, } & l = A^* + (l-A) * \frac{B^*-A^*}{B-A} \end{array} \right.\)

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:

#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageTools.h>
#include <visp3/io/vpImageIo.h>

int main()
{
  vpImage<unsigned char> I;
#ifdef _WIN32
  std::string filename("C:/Temp/visp-images/Klimt/Klimt.ppm");
#else
  std::string filename("/local/soft/ViSP/ViSP-images/Klimt/Klimt.ppm");
#endif

  // Read an image from the disk
  vpImageIo::read(I, filename);

  // Binarize image I:
  // - gray level values less than or equal to 127 are set to 0,
  // - gray level values greater than 128 are set to 255
  vpImageTools::changeLUT(I, 127, 0, 128, 255);

  vpImageIo::write(I, "Klimt.pgm"); // Write the image in a PGM P5 image file format
}
Parameters:
I: visp._visp.core.ImageGray

Image to process.

A: int

Low gray level value of the range to consider.

B: int

Height gray level value of the range to consider.

static columnMean(I: visp._visp.core.ImageDouble, result: visp._visp.core.RowVector) None

Compute the column-wise mean intensities.

Parameters:
I: visp._visp.core.ImageDouble

The image.

static crop(*args, **kwargs)

Overloaded function.

  1. crop(I: visp._visp.core.ImageGray, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: visp._visp.core.ImageGray, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageUInt16, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: visp._visp.core.ImageUInt16, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageFloat, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: visp._visp.core.ImageFloat, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageDouble, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: visp._visp.core.ImageDouble, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: vpImage<bool>, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: vpImage<bool>, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageRGBa, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: visp._visp.core.ImageRGBa, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageRGBf, roi_top: float, roi_left: float, roi_height: int, roi_width: int, crop: visp._visp.core.ImageRGBf, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageGray, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: visp._visp.core.ImageGray, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageUInt16, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: visp._visp.core.ImageUInt16, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageFloat, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: visp._visp.core.ImageFloat, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageDouble, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: visp._visp.core.ImageDouble, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: vpImage<bool>, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: vpImage<bool>, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageRGBa, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: visp._visp.core.ImageRGBa, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageRGBf, topLeft: visp._visp.core.ImagePoint, roi_height: int, roi_width: int, crop: visp._visp.core.ImageRGBf, v_scale: int = 1, h_scale: int = 1) -> None

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.

Note

See crop(const vpImage<Type> &, const vpRect &, vpImage<Type> &)

Parameters:
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.

  1. crop(I: visp._visp.core.ImageGray, roi: visp._visp.core.Rect, crop: visp._visp.core.ImageGray, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

  1. crop(I: visp._visp.core.ImageUInt16, roi: visp._visp.core.Rect, crop: visp._visp.core.ImageUInt16, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

  1. crop(I: visp._visp.core.ImageFloat, roi: visp._visp.core.Rect, crop: visp._visp.core.ImageFloat, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

  1. crop(I: visp._visp.core.ImageDouble, roi: visp._visp.core.Rect, crop: visp._visp.core.ImageDouble, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

  1. crop(I: vpImage<bool>, roi: visp._visp.core.Rect, crop: vpImage<bool>, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

  1. crop(I: visp._visp.core.ImageRGBa, roi: visp._visp.core.Rect, crop: visp._visp.core.ImageRGBa, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

  1. crop(I: visp._visp.core.ImageRGBf, roi: visp._visp.core.Rect, crop: visp._visp.core.ImageRGBf, v_scale: int = 1, h_scale: int = 1) -> None

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.

Parameters:
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.

static extract(*args, **kwargs)

Overloaded function.

  1. extract(src: visp._visp.core.ImageGray, dst: visp._visp.core.ImageGray, r: visp._visp.core.RectOriented) -> None

Extract a rectangular region from an image.

Parameters:
src

The source image.

dst

The resulting image.

r

The rectangle area.

  1. extract(src: visp._visp.core.ImageGray, dst: visp._visp.core.ImageDouble, r: visp._visp.core.RectOriented) -> None

Extract a rectangular region from an image.

Parameters:
src

The source image.

dst

The resulting image.

r

The rectangle area.

static imageAdd(I1: visp._visp.core.ImageGray, I2: visp._visp.core.ImageGray, Ires: visp._visp.core.ImageGray, saturate: bool = false) None

Compute the image addition: \(Ires = I1 + I2\) .

Note

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

Warning

This function does not work in-place (Ires object must be different from I1 and I2).

Parameters:
I1: visp._visp.core.ImageGray

The first image.

I2: visp._visp.core.ImageGray

The second image.

Ires: visp._visp.core.ImageGray

math:Ires = I1 + I2

saturate: bool = false

If true, saturate the result to [0 ; 255] using vpMath::saturate , otherwise overflow may occur.

static imageDifference(*args, **kwargs)

Overloaded function.

  1. imageDifference(I1: visp._visp.core.ImageGray, I2: visp._visp.core.ImageGray, Idiff: visp._visp.core.ImageGray) -> None

Compute the signed difference between the two images I1 and I2 for visualization purpose: Idiff = I1-I2

  • pixels with a null difference are set to 128.

  • A negative difference implies a pixel value < 128

  • A positive difference implies a pixel value > 128

Parameters:
I1

The first image.

I2

The second image.

Idiff

The result of the difference.

  1. imageDifference(I1: visp._visp.core.ImageRGBa, I2: visp._visp.core.ImageRGBa, Idiff: visp._visp.core.ImageRGBa) -> None

Compute the signed difference between the two images I1 and I2 RGB components for visualization purpose: Idiff = I1-I2. The fourth component named A is not compared. It is set to 0 in the resulting difference image.

  • pixels with a null difference are set to R=128, G=128, B=128.

  • A negative difference implies a pixel R, G, B value < 128

  • A positive difference implies a pixel R, G, B value > 128

Parameters:
I1

The first image.

I2

The second image.

Idiff

The result of the difference between RGB components.

static imageDifferenceAbsolute(*args, **kwargs)

Overloaded function.

  1. imageDifferenceAbsolute(I1: visp._visp.core.ImageGray, I2: visp._visp.core.ImageGray, Idiff: visp._visp.core.ImageGray) -> None

Compute the difference between the two images I1 and I2

Warning

: This is NOT for visualization If you want to visualize difference images during servo, please use vpImageTools::imageDifference (..,..,..) function.

Parameters:
I1

The first image.

I2

The second image.

Idiff

The result of the difference.

  1. imageDifferenceAbsolute(I1: visp._visp.core.ImageDouble, I2: visp._visp.core.ImageDouble, Idiff: visp._visp.core.ImageDouble) -> None

Compute the difference between the two images I1 and I2.

Parameters:
I1

The first image.

I2

The second image.

Idiff

The result of the difference.

  1. imageDifferenceAbsolute(I1: visp._visp.core.ImageRGBa, I2: visp._visp.core.ImageRGBa, Idiff: visp._visp.core.ImageRGBa) -> None

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.

Warning

: This is NOT for visualization. If you want to visualize difference images during servo, please use vpImageTools::imageDifference (..,..,..) function.

Parameters:
I1

The first image.

I2

The second image.

Idiff

The result of the difference between RGB components.

static imageSubtract(I1: visp._visp.core.ImageGray, I2: visp._visp.core.ImageGray, Ires: visp._visp.core.ImageGray, saturate: bool = false) None

Compute the image addition: \(Ires = I1 - I2\) .

Note

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

Warning

This function does not work in-place (Ires object must be different from I1 and I2).

Parameters:
I1: visp._visp.core.ImageGray

The first image.

I2: visp._visp.core.ImageGray

The second image.

Ires: visp._visp.core.ImageGray

math:Ires = I1 - I2

saturate: bool = false

If true, saturate the result to [0 ; 255] using vpMath::saturate , otherwise overflow may occur.

static inMask(*args, **kwargs)

Overloaded function.

  1. inMask(I: visp._visp.core.ImageGray, mask: visp._visp.core.ImageGray, I_mask: visp._visp.core.ImageGray) -> int

Parameters:
I

Input image.

mask

Mask where pixels to consider have values that differ from 0.

I_mask

Resulting image where pixels that are in the mask are kept.

Returns:

The number of pixels that are in the mask.

  1. inMask(I: visp._visp.core.ImageRGBa, mask: visp._visp.core.ImageGray, I_mask: visp._visp.core.ImageRGBa) -> int

Parameters:
I

Input image.

mask

Mask where pixels to consider have values that differ from 0.

I_mask

Resulting image where pixels that are in the mask are kept.

Returns:

The number of pixels that are in the mask.

static initUndistortMap(cam: visp._visp.core.CameraParameters, width: int, height: int, mapU: vpArray2D<int>, mapV: vpArray2D<int>, mapDu: vpArray2D<float>, mapDv: vpArray2D<float>) None

Compute the undistortion transformation map.

Parameters:
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 \(\Delta u\) for the interpolation.

mapDv

2D array that contains at each coordinate the \(\Delta v\) for the interpolation.

static integralImage(I: visp._visp.core.ImageGray, II: visp._visp.core.ImageDouble, IIsq: visp._visp.core.ImageDouble) None

Compute the integral images:

\(II(u,v)=\sum_{u^{'}\leq u, v^{'}\leq v}I(u,v)\)

\(IIsq(u,v)=\sum_{u^{'}\leq u, v^{'}\leq v}I(u,v)^2\) .

Parameters:
I: visp._visp.core.ImageGray

Input image.

II: visp._visp.core.ImageDouble

Integral image II.

IIsq: visp._visp.core.ImageDouble

Integral image IIsq.

static interpolate(I: visp._visp.core.ImageGray, point: visp._visp.core.ImagePoint, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST) float
static normalize(I: visp._visp.core.ImageDouble) None

Normalize the image intensities.

Parameters:
I: visp._visp.core.ImageDouble

The image to normalize.

static normalizedCorrelation(I1: visp._visp.core.ImageDouble, I2: visp._visp.core.ImageDouble, useOptimized: bool = true) float

Compute a correlation between 2 images.

Parameters:
I1: visp._visp.core.ImageDouble

The first image.

I2: visp._visp.core.ImageDouble

The second image.

useOptimized: bool = true

Use SSE if true and available.

static remap(*args, **kwargs)

Overloaded function.

  1. remap(I: visp._visp.core.ImageGray, mapU: vpArray2D<int>, mapV: vpArray2D<int>, mapDu: vpArray2D<float>, mapDv: vpArray2D<float>, Iundist: visp._visp.core.ImageGray) -> None

Apply the transformation map to the image.

Parameters:
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 \(\Delta u\) for the interpolation.

mapDv

Map that contains at each destination coordinate the \(\Delta v\) for the interpolation.

Iundist

Output transformed grayscale image.

  1. remap(I: visp._visp.core.ImageRGBa, mapU: vpArray2D<int>, mapV: vpArray2D<int>, mapDu: vpArray2D<float>, mapDv: vpArray2D<float>, Iundist: visp._visp.core.ImageRGBa) -> None

Apply the transformation map to the image.

Parameters:
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 \(\Delta u\) for the interpolation.

mapDv

Map that contains at each destination coordinate the \(\Delta v\) for the interpolation.

Iundist

Output transformed color image.

static templateMatching(I: visp._visp.core.ImageGray, I_tpl: visp._visp.core.ImageGray, I_score: visp._visp.core.ImageDouble, step_u: int, step_v: int, useOptimized: bool = true) None

Match a template image into another image using zero-mean normalized cross-correlation:

\(\frac{\sum_{u^{'},v^{'}} (I(u+u^{'},v+v^{'})-\bar{I}_{u^{'},v^{'}}) (T(u^{'},v^{'})-\bar{T}_{u^{'},v^{'}})}{\sqrt{\sum_{u^{'},v^{'}} (I(u+u^{'},v+v^{'})-\bar{I}_{u^{'},v^{'}})^2 \sum_{u^{'},v^{'}}(T(u^{'},v^{'})-\bar{T}_{u^{'},v^{'}})^2}}\)

Parameters:
I: visp._visp.core.ImageGray

Input image.

I_tpl: visp._visp.core.ImageGray

Template image.

I_score: visp._visp.core.ImageDouble

Output template matching score.

step_u: int

Step in u-direction to speed-up the computation.

step_v: int

Step in v-direction to speed-up the computation.

useOptimized: bool = true

Use optimized version (SSE, OpenMP, integral images, …) if true and available.

static warpImage(*args, **kwargs)

Overloaded function.

  1. warpImage(src: visp._visp.core.ImageGray, T: visp._visp.core.Matrix, dst: visp._visp.core.ImageGray, interpolation: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, fixedPointArithmetic: bool = true, pixelCenter: bool = false) -> None

  2. warpImage(src: visp._visp.core.ImageFloat, T: visp._visp.core.Matrix, dst: visp._visp.core.ImageFloat, interpolation: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, fixedPointArithmetic: bool = true, pixelCenter: bool = false) -> None

  3. warpImage(src: visp._visp.core.ImageDouble, T: visp._visp.core.Matrix, dst: visp._visp.core.ImageDouble, interpolation: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, fixedPointArithmetic: bool = true, pixelCenter: bool = false) -> None

  4. warpImage(src: visp._visp.core.ImageUInt16, T: visp._visp.core.Matrix, dst: visp._visp.core.ImageUInt16, interpolation: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, fixedPointArithmetic: bool = true, pixelCenter: bool = false) -> None

  5. warpImage(src: visp._visp.core.ImageRGBa, T: visp._visp.core.Matrix, dst: visp._visp.core.ImageRGBa, interpolation: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, fixedPointArithmetic: bool = true, pixelCenter: bool = false) -> None