ImageTools¶
- class ImageTools¶
Bases:
pybind11_object
Various image tools; sub-image extraction, modification of the look up table, binarisation…
Methods
Overloaded function.
Change the look up table (LUT) of an image.
Compute the column-wise mean intensities.
Overloaded function.
Overloaded function.
Overloaded function.
Compute the image addition: \(Ires = I1 + I2\) .
Overloaded function.
Overloaded function.
Compute the image addition: \(Ires = I1 - I2\) .
Overloaded function.
Compute the undistortion transformation map.
Compute the integral images:
Normalize the image intensities.
Compute a correlation between 2 images.
Overloaded function.
Overloaded function.
Match a template image into another image using zero-mean normalized cross-correlation:
Overloaded function.
Overloaded function.
Inherited Methods
Operators
__doc__
__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).
- static binarise(*args, **kwargs)¶
Overloaded function.
binarise(I: visp._visp.core.ImageGray, threshold1: int, threshold2: int, value1: int, value2: int, value3: int, useLUT: bool = true) -> None
Binarise an image.
Pixels whose values are less than threshold1 are set to value1
Pixels whose values are greater then or equal to threshold1 and less then or equal to threshold2 are set to value2
Pixels whose values are greater than threshold2 are set to value3
binarise(I: visp._visp.core.ImageFloat, threshold1: float, threshold2: float, value1: float, value2: float, value3: float, useLUT: bool = true) -> None
Binarise an image.
Pixels whose values are less than threshold1 are set to value1
Pixels whose values are greater then or equal to threshold1 and less then or equal to threshold2 are set to value2
Pixels whose values are greater than threshold2 are set to value3
binarise(I: visp._visp.core.ImageDouble, threshold1: float, threshold2: float, value1: float, value2: float, value3: float, useLUT: bool = true) -> None
Binarise an image.
Pixels whose values are less than threshold1 are set to value1
Pixels whose values are greater then or equal to threshold1 and less then or equal to threshold2 are set to value2
Pixels whose values are greater than threshold2 are set to value3
binarise(I: visp._visp.core.ImageRGBa, threshold1: visp._visp.core.RGBa, threshold2: visp._visp.core.RGBa, value1: visp._visp.core.RGBa, value2: visp._visp.core.RGBa, value3: visp._visp.core.RGBa, useLUT: bool = true) -> None
Binarise an image.
Pixels whose values are less than threshold1 are set to value1
Pixels whose values are greater then or equal to threshold1 and less then or equal to threshold2 are set to value2
Pixels whose values are greater than threshold2 are set to value3
- static changeLUT(I: 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> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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 }
- static columnMean(I: visp.core.ImageDouble, result: visp.core.RowVector) None ¶
Compute the column-wise mean intensities.
- Parameters:
- I: visp.core.ImageDouble¶
The image.
- static crop(*args, **kwargs)¶
Overloaded function.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 flip(*args, **kwargs)¶
Overloaded function.
flip(I: visp._visp.core.ImageGray, newI: visp._visp.core.ImageGray) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: visp._visp.core.ImageUInt16, newI: visp._visp.core.ImageUInt16) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: visp._visp.core.ImageFloat, newI: visp._visp.core.ImageFloat) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: visp._visp.core.ImageDouble, newI: visp._visp.core.ImageDouble) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: vpImage<bool>, newI: vpImage<bool>) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: visp._visp.core.ImageRGBa, newI: visp._visp.core.ImageRGBa) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: visp._visp.core.ImageRGBf, newI: visp._visp.core.ImageRGBf) -> None
Flip vertically the input image and give the result in the output image.
- Parameters:
- I
Input image to flip.
- newI
Output image which is the flipped input image.
flip(I: visp._visp.core.ImageGray) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
flip(I: visp._visp.core.ImageUInt16) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
flip(I: visp._visp.core.ImageFloat) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
flip(I: visp._visp.core.ImageDouble) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
flip(I: vpImage<bool>) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
flip(I: visp._visp.core.ImageRGBa) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
flip(I: visp._visp.core.ImageRGBf) -> None
Flip vertically the input image.
The following example shows how to use this function:
#include <visp3/core/vpImage.h> #include <visp3/core/vpImageTools.h> #include <visp3/io/vpImageIo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImage<vpRGBa> 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); // Flip the image vpImageTools::flip(I); // Write the image in a PGM P5 image file format vpImageIo::write(I, "Klimt-flip.ppm"); }
- Parameters:
- I
Input image which is flipped and modified in output.
-
static imageAdd(I1: visp.core.ImageGray, I2: visp.core.ImageGray, Ires: 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.core.ImageGray¶
The first image.
- I2: visp.core.ImageGray¶
The second image.
- Ires: 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.
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.
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.
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.
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.
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.core.ImageGray, I2: visp.core.ImageGray, Ires: 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.core.ImageGray¶
The first image.
- I2: visp.core.ImageGray¶
The second image.
- Ires: 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.
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.
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.core.ImageGray, II: visp.core.ImageDouble, IIsq: 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.core.ImageGray¶
Input image.
- II: visp.core.ImageDouble¶
Integral image II.
- IIsq: visp.core.ImageDouble¶
Integral image IIsq.
-
static interpolate(I: visp.core.ImageGray, point: visp.core.ImagePoint, method: visp.core.ImageTools.ImageInterpolationType =
INTERPOLATION_NEAREST
) float ¶
- static normalize(I: visp.core.ImageDouble) None ¶
Normalize the image intensities.
- Parameters:
- I: visp.core.ImageDouble¶
The image to normalize.
-
static normalizedCorrelation(I1: visp.core.ImageDouble, I2: visp.core.ImageDouble, useOptimized: bool =
true
) float ¶ Compute a correlation between 2 images.
- Parameters:
- I1: visp.core.ImageDouble¶
The first image.
- I2: visp.core.ImageDouble¶
The second image.
- useOptimized: bool =
true
¶ Use SSE if true and available.
- static remap(*args, **kwargs)¶
Overloaded function.
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.
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 resize(*args, **kwargs)¶
Overloaded function.
resize(I: visp._visp.core.ImageGray, Ires: visp._visp.core.ImageGray, width: int, height: int, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, nThreads: int = 0) -> None
resize(I: visp._visp.core.ImageUInt16, Ires: visp._visp.core.ImageUInt16, width: int, height: int, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, nThreads: int = 0) -> None
resize(I: visp._visp.core.ImageFloat, Ires: visp._visp.core.ImageFloat, width: int, height: int, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, nThreads: int = 0) -> None
resize(I: visp._visp.core.ImageGray, Ires: visp._visp.core.ImageGray, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, nThreads: int = 0) -> None
resize(I: visp._visp.core.ImageUInt16, Ires: visp._visp.core.ImageUInt16, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, nThreads: int = 0) -> None
resize(I: visp._visp.core.ImageFloat, Ires: visp._visp.core.ImageFloat, method: visp._visp.core.ImageTools.ImageInterpolationType = INTERPOLATION_NEAREST, nThreads: int = 0) -> None
-
static templateMatching(I: visp.core.ImageGray, I_tpl: visp.core.ImageGray, I_score: 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.core.ImageGray¶
Input image.
- I_tpl: visp.core.ImageGray¶
Template image.
- I_score: 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 undistort(*args, **kwargs)¶
Overloaded function.
undistort(I: visp._visp.core.ImageGray, cam: visp._visp.core.CameraParameters, newI: visp._visp.core.ImageGray, nThreads: int = 2) -> None
Undistort an image
Warning
This function works only with Types authorizing “+,-, multiplication by a scalar” operators.
Since this function is time consuming, if you want to undistort multiple images, you should rather call initUndistortMap() once and then remap() to undistort the images. This will be less time consuming.
Note
See initUndistortMap() , remap()
- Parameters:
- I
Input image to undistort.
- cam
Parameters of the camera causing distortion.
- nThreads
Number of threads to use if pthreads library is available.
undistort(I: visp._visp.core.ImageRGBa, cam: visp._visp.core.CameraParameters, newI: visp._visp.core.ImageRGBa, nThreads: int = 2) -> None
Undistort an image
Warning
This function works only with Types authorizing “+,-, multiplication by a scalar” operators.
Since this function is time consuming, if you want to undistort multiple images, you should rather call initUndistortMap() once and then remap() to undistort the images. This will be less time consuming.
Note
See initUndistortMap() , remap()
- Parameters:
- I
Input image to undistort.
- cam
Parameters of the camera causing distortion.
- nThreads
Number of threads to use if pthreads library is available.
undistort(I: visp._visp.core.ImageGray, mapU: vpArray2D<int>, mapV: vpArray2D<int>, mapDu: vpArray2D<float>, mapDv: vpArray2D<float>, newI: visp._visp.core.ImageGray) -> None
Undistort an image.
Note
To undistort a fisheye image, you have to first call initUndistortMap() function to calculate maps and then call undistort() with input maps.
- Parameters:
- I
Input image to undistort.
- 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.
- newI
Undistorted output image. The size of this image will be the same as the input image I .
undistort(I: visp._visp.core.ImageRGBa, mapU: vpArray2D<int>, mapV: vpArray2D<int>, mapDu: vpArray2D<float>, mapDv: vpArray2D<float>, newI: visp._visp.core.ImageRGBa) -> None
Undistort an image.
Note
To undistort a fisheye image, you have to first call initUndistortMap() function to calculate maps and then call undistort() with input maps.
- Parameters:
- I
Input image to undistort.
- 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.
- newI
Undistorted output image. The size of this image will be the same as the input image I .
- static warpImage(*args, **kwargs)¶
Overloaded function.
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
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
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
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