ImageDouble¶
- class ImageDouble(*args, **kwargs)¶
Bases:
pybind11_object
Definition of the vpImage class member functions.
This is a template class, therefore the type of each element of the array is not a priori defined.
Data structure¶
Each image is build using two structure (an array bitmap which size is [width*height]) and an array of pointer row (which size is [nrow]) the ith element in the row array row[i] is pointer toward the ith “line” of the image (ie, bitmap +i*width )
<unparsed image <doxmlparser.compound.docImageType object at 0x7f4c71cc6f50>>
Such a structure allows a fast access to each element of the image. if i is the ith rows and j the jth columns the value of this pixel is given by I[i][j] (that is equivalent to row[i][j]).
Example¶
The following example available in tutorial-image-manipulation.cpp shows how to create gray level and color images and how to access to the pixels.
#include <visp3/core/vpConfig.h> #include <visp3/core/vpImage.h> int main() { #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME ; #endif try { vpImage<unsigned char> gray_image(240, 320); vpImage<vpRGBa> color_image(240, 320); gray_image = 128; vpRGBa color(255, 0, 0); color_image = color; unsigned int igray_max = gray_image.getHeight() - 1; unsigned int jgray_max = gray_image.getWidth() - 1; std::cout << "Gray image, last pixel intensity: " << (int)gray_image[igray_max][jgray_max] << std::endl; unsigned int icolor_max = color_image.getHeight() - 1; unsigned int jcolor_max = color_image.getWidth() - 1; std::cout << "Color image, last pixel RGB components: " << (int)color_image[icolor_max][jcolor_max].R << " " << (int)color_image[icolor_max][jcolor_max].G << " " << (int)color_image[icolor_max][jcolor_max].B << std::endl; } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } }
Important remark¶
To provide high-performance access there is no verification to ensure that 0 \(\le\) i < height and 0 \(\le\) j < width. Since the memory allocated in the bitmap array is continuous, that means that if (i, j) is outside the image you will manipulate a pixel that is not as expected. To highlight this remark, we provide hereafter an example where the considered pixel is outside the image:
unsigned int width = 320; unsigned int height = 240; vpImage<unsigned char> I(height, width); // Create an 320x240 image // Set pixel coordinates that is outside the image unsigned int i = 100; unsigned int j = 400; unsigned char value; value = I[i][j]; // Here we will get the pixel value at position (101, 80)
Overloaded function.
__init__(self: visp._visp.core.ImageDouble) -> None
constructor
__init__(self: visp._visp.core.ImageDouble, img: visp._visp.core.ImageDouble) -> None
__init__(self: visp._visp.core.ImageDouble, height: int, width: int) -> None
constructor set the size of the image
__init__(self: visp._visp.core.ImageDouble, height: int, width: int, value: float) -> None
__init__(self: visp._visp.core.ImageDouble, np_array: numpy.ndarray[numpy.float64]) -> None
Construct an image by copying a 2D numpy array.
- param np_array:
The numpy array to copy.
Methods
Overloaded function.
Destructor : Memory de-allocation.
Get the number of columns in the image.
Get the image height.
Look for the minimum and the maximum value within the double bitmap.
Get the image number of pixels which corresponds to the image width multiplied by the image height.
Get the number of rows in the image.
Get the image size.
Overloaded function.
Get the image width.
Overloaded function.
Numpy view of the underlying image data.
Overloaded function.
Overloaded function.
Inherited Methods
Operators
Overloaded function.
__doc__
Overloaded function.
Overloaded function.
__module__
__repr__
Overloaded function.
Attributes
__annotations__
- __call__(*args, **kwargs)¶
Overloaded function.
__call__(self: visp._visp.core.ImageDouble, i: int, j: int) -> float
__call__(self: visp._visp.core.ImageDouble, i: int, j: int, v: float) -> None
__call__(self: visp._visp.core.ImageDouble, ip: visp._visp.core.ImagePoint, v: float) -> None
- __eq__(self, I: visp._visp.core.ImageDouble) bool ¶
- __getitem__(*args, **kwargs)¶
Overloaded function.
__getitem__(self: visp._visp.core.ImageDouble, arg0: tuple[int, int]) -> float
__getitem__(self: visp._visp.core.ImageDouble, arg0: int) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.ImageDouble, arg0: slice) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.ImageDouble, arg0: tuple) -> numpy.ndarray[numpy.float64]
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.ImageDouble) -> None
constructor
__init__(self: visp._visp.core.ImageDouble, img: visp._visp.core.ImageDouble) -> None
__init__(self: visp._visp.core.ImageDouble, height: int, width: int) -> None
constructor set the size of the image
__init__(self: visp._visp.core.ImageDouble, height: int, width: int, value: float) -> None
__init__(self: visp._visp.core.ImageDouble, np_array: numpy.ndarray[numpy.float64]) -> None
Construct an image by copying a 2D numpy array.
- Parameters:
- np_array
The numpy array to copy.
- __ne__(self, I: visp._visp.core.ImageDouble) bool ¶
- __setitem__(*args, **kwargs)¶
Overloaded function.
__setitem__(self: visp._visp.core.ImageDouble, arg0: tuple[int, int], arg1: float) -> None
__setitem__(self: visp._visp.core.ImageDouble, arg0: int, arg1: float) -> None
__setitem__(self: visp._visp.core.ImageDouble, arg0: slice, arg1: float) -> None
__setitem__(self: visp._visp.core.ImageDouble, arg0: tuple[slice, slice], arg1: float) -> None
__setitem__(self: visp._visp.core.ImageDouble, arg0: int, arg1: numpy.ndarray[numpy.float64]) -> None
__setitem__(self: visp._visp.core.ImageDouble, arg0: slice, arg1: numpy.ndarray[numpy.float64]) -> None
- __sub__(self, B: visp._visp.core.ImageDouble) visp._visp.core.ImageDouble ¶
- destroy(self) None ¶
Destructor : Memory de-allocation.
Warning
does not deallocate memory for display and video
- doubleSizeImage(self, res: visp._visp.core.ImageDouble) None ¶
- getCols(self) int ¶
Get the number of columns in the image.
Note
See getWidth()
- Returns:
The image number of column, or image width.
- getMinMaxValue(self, min: float, max: float, onlyFiniteVal: bool = true) None ¶
Look for the minimum and the maximum value within the double bitmap.
Note
See getMaxValue()
Note
See getMinValue()
Note
See getMinMaxLoc()
- getNumberOfPixel(self) int ¶
Get the image number of pixels which corresponds to the image width multiplied by the image height.
Note
See getWidth() , getHeight()
- Returns:
The image number of pixels or image size.
- getRows(self) int ¶
Get the number of rows in the image.
Note
See getHeight()
- Returns:
The image number of rows, or image height.
- getSize(self) int ¶
Get the image size.
Note
See getWidth() , getHeight()
- Returns:
The image size = width * height.
- getValue(*args, **kwargs)¶
Overloaded function.
getValue(self: visp._visp.core.ImageDouble, i: int, j: int) -> float
getValue(self: visp._visp.core.ImageDouble, i: float, j: float) -> float
getValue(self: visp._visp.core.ImageDouble, ip: visp._visp.core.ImagePoint) -> float
- halfSizeImage(self, res: visp._visp.core.ImageDouble) None ¶
- init(*args, **kwargs)¶
Overloaded function.
init(self: visp._visp.core.ImageDouble, height: int, width: int) -> None
Set the size of the image.
init(self: visp._visp.core.ImageDouble, height: int, width: int, value: float) -> None
- insert(self, src: visp._visp.core.ImageDouble, topLeft: visp._visp.core.ImagePoint) None ¶
- numpy(self) numpy.ndarray[numpy.float64] ¶
Numpy view of the underlying image data. This numpy view can be used to directly modify the array.
- quarterSizeImage(self, res: visp._visp.core.ImageDouble) None ¶
- resize(*args, **kwargs)¶
Overloaded function.
resize(self: visp._visp.core.ImageDouble, h: int, w: int) -> None
resize the image : Image initialization
Allocate memory for an [height x width] image.
Warning
The image is not initialized.
Element of the bitmap are not initialized
If the image has been already initialized, memory allocation is done only if the new image size is different, else we re-use the same memory space.
Note
See init(unsigned int, unsigned int)
- Parameters:
- h
Image height.
- w
Image width.
resize(self: visp._visp.core.ImageDouble, h: int, w: int, val: float) -> None
- sub(*args, **kwargs)¶
Overloaded function.
sub(self: visp._visp.core.ImageDouble, B: visp._visp.core.ImageDouble, C: visp._visp.core.ImageDouble) -> None
sub(self: visp._visp.core.ImageDouble, A: visp._visp.core.ImageDouble, B: visp._visp.core.ImageDouble, C: visp._visp.core.ImageDouble) -> None
- subsample(self, v_scale: int, h_scale: int, sampled: visp._visp.core.ImageDouble) None ¶
-
__hash__ =
None
¶