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.

  1. __init__(self: visp._visp.core.ImageDouble) -> None

constructor

  1. __init__(self: visp._visp.core.ImageDouble, img: visp._visp.core.ImageDouble) -> None

  2. __init__(self: visp._visp.core.ImageDouble, height: int, width: int) -> None

constructor set the size of the image

  1. __init__(self: visp._visp.core.ImageDouble, height: int, width: int, value: float) -> None

  2. __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

__init__

Overloaded function.

destroy

Destructor : Memory de-allocation.

doubleSizeImage

getCols

Get the number of columns in the image.

getHeight

Get the image height.

getMaxValue

getMinMaxValue

Look for the minimum and the maximum value within the double bitmap.

getMinValue

getNumberOfPixel

Get the image number of pixels which corresponds to the image width multiplied by the image height.

getRows

Get the number of rows in the image.

getSize

Get the image size.

getValue

Overloaded function.

getWidth

Get the image width.

halfSizeImage

init

Overloaded function.

insert

numpy

Numpy view of the underlying image data.

quarterSizeImage

resize

Overloaded function.

sub

Overloaded function.

subsample

Inherited Methods

Operators

__call__

Overloaded function.

__doc__

__eq__

__getitem__

Overloaded function.

__hash__

__init__

Overloaded function.

__module__

__ne__

__repr__

__setitem__

Overloaded function.

__sub__

Attributes

__annotations__

__hash__

__call__(*args, **kwargs)

Overloaded function.

  1. __call__(self: visp._visp.core.ImageDouble, i: int, j: int) -> float

  2. __call__(self: visp._visp.core.ImageDouble, i: int, j: int, v: float) -> None

  3. __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.

  1. __getitem__(self: visp._visp.core.ImageDouble, arg0: tuple[int, int]) -> float

  2. __getitem__(self: visp._visp.core.ImageDouble, arg0: int) -> numpy.ndarray[numpy.float64]

  3. __getitem__(self: visp._visp.core.ImageDouble, arg0: slice) -> numpy.ndarray[numpy.float64]

  4. __getitem__(self: visp._visp.core.ImageDouble, arg0: tuple) -> numpy.ndarray[numpy.float64]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.core.ImageDouble) -> None

constructor

  1. __init__(self: visp._visp.core.ImageDouble, img: visp._visp.core.ImageDouble) -> None

  2. __init__(self: visp._visp.core.ImageDouble, height: int, width: int) -> None

constructor set the size of the image

  1. __init__(self: visp._visp.core.ImageDouble, height: int, width: int, value: float) -> None

  2. __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.

  1. __setitem__(self: visp._visp.core.ImageDouble, arg0: tuple[int, int], arg1: float) -> None

  2. __setitem__(self: visp._visp.core.ImageDouble, arg0: int, arg1: float) -> None

  3. __setitem__(self: visp._visp.core.ImageDouble, arg0: slice, arg1: float) -> None

  4. __setitem__(self: visp._visp.core.ImageDouble, arg0: tuple[slice, slice], arg1: float) -> None

  5. __setitem__(self: visp._visp.core.ImageDouble, arg0: int, arg1: numpy.ndarray[numpy.float64]) -> None

  6. __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.

getHeight(self) int

Get the image height.

Note

See getWidth()

Returns:

The image height.

getMaxValue(self, onlyFiniteVal: bool = true) float
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()

Parameters:
min: float

The minimal value within the bitmap.

max: float

The maximal value within the bitmap.

onlyFiniteVal: bool = true

If true, consider only finite values.

getMinValue(self, onlyFiniteVal: bool = true) float
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.

  1. getValue(self: visp._visp.core.ImageDouble, i: int, j: int) -> float

  2. getValue(self: visp._visp.core.ImageDouble, i: float, j: float) -> float

  3. getValue(self: visp._visp.core.ImageDouble, ip: visp._visp.core.ImagePoint) -> float

getWidth(self) int

Get the image width.

Note

See getHeight()

Returns:

The image width.

halfSizeImage(self, res: visp._visp.core.ImageDouble) None
init(*args, **kwargs)

Overloaded function.

  1. init(self: visp._visp.core.ImageDouble, height: int, width: int) -> None

Set the size of the image.

  1. 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.

  1. 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.

  1. resize(self: visp._visp.core.ImageDouble, h: int, w: int, val: float) -> None

sub(*args, **kwargs)

Overloaded function.

  1. sub(self: visp._visp.core.ImageDouble, B: visp._visp.core.ImageDouble, C: visp._visp.core.ImageDouble) -> None

  2. 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