Coordinate matrices
- machinevisiontoolbox.base.meshgrid.meshgrid(width, height)[source]
Coordinate arrays for an image
- Parameters:
width (int) – image width in pixels
height (int) – image height in pixels
- Returns:
coordinate arrays
- Return type:
ndarray(H,W), ndarray(H,W)
Returns arrays
U
andV
such thatU[u,v] = u
andV[u,v] = v
. This can be used to define a 2D-function, for example:>>> from machinevisiontoolbox import meshgrid >>> U, V = meshgrid(3, 4) >>> U array([[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]]) >>> V array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3]]) >>> Z = U**2 + V**2 # z=u^2 + v^2 >>> Z array([[ 0, 1, 4], [ 1, 2, 5], [ 4, 5, 8], [ 9, 10, 13]])
- Seealso:
Image.warp
meshgrid
- machinevisiontoolbox.base.meshgrid.spherical_rotate(Phi, Theta, R)[source]
Rotate coordinate matrices for a spherical image
- Parameters:
Phi (ndarray(H,W)) – coordinate array for azimuth
Theta (ndarray(H,W)) – coordinate array for colatitude
R (
spatialmath.pose3d.SO3
) – an SO(3) rotation matrix
- Returns:
transformed coordinate arrays
- Return type:
ndarray(H,W), ndarray(H,W)
The coordinates of points in a spherical image can be represented by a pair of coordinate matrices that describe azimuth \(\phi \in [0, 2\pi]\) and colatitude \(\theta \in [0, \pi]\) for each pixel:
Phi[u,v]
\(=\phi_{u,v}\),Theta[u,v]
\(=\theta_{u,v}\).This function rotates the spherical image about its centre by transforming the coordinate arrays
\[\begin{split}\begin{pmatrix} \phi^\prime_{u,v} \\ \theta^\prime_{u,v} \end{pmatrix} = \mat{R} \begin{pmatrix} \phi_{u,v} \\ \theta_{u,v} \end{pmatrix}, \forall u, v\end{split}\]- Seealso: