machinevisiontoolbox.Image.meshgrid

Image.meshgrid(width=None, height=None, step=1)

Coordinate arrays for image

Parameters:
  • width (int, optional) – width of array in pixels, defaults to width of image

  • height (int, optional) – height of array in pixels, defaults to height of image

Returns:

domain of image

Rtype u:

ndarray(H,W), ndarray(H,W)

Create a pair of arrays U and V that describe the domain of the image. The element U(u,v) = u and V(u,v) = v. These matrices can be used for the evaluation of functions over the image such as interpolation and warping.

Invoking as a class method with self=None is a convenient way to access base.meshgrid.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Zeros(3)
>>> U, V = img.meshgrid()
>>> U
array([[0, 1, 2],
       [0, 1, 2],
       [0, 1, 2]])
>>> V
array([[0, 0, 0],
       [1, 1, 1],
       [2, 2, 2]])
>>> Image(U**2 + V**2).image
array([[0, 1, 4],
       [1, 2, 5],
       [4, 5, 8]])
>>> U, V = Image.meshgrid(None, 4, 4)
>>> U
array([[0, 1, 2, 3],
       [0, 1, 2, 3],
       [0, 1, 2, 3],
       [0, 1, 2, 3]])
Seealso:

meshgrid