Generate grid

Generate grid

Generates a set points that uniformly covers the pixel grid of an image. With an iteration this tool can be used to apply an operation to sub-images.

To split an input image into fixed-size pieces, iterated grid corners can be used as an input to pixel-to-world coordinate transform followed by cropping. To apply an operation to sub-images without cropping one can connect the iterated grid corners as the frame input for many tools such as histogram.

Inputs

image
The image to cover with a grid.
gridSpacing
The horizontal and vertical spacing between points in pixel coordinates.
gridPosition
Specifies how the grid should be positioned.

Outputs

corners
The coordinates of the upper left corners of each grid cell in world coordinates in row-major order. A N-by-2 matrix. Note that due to perspective and non-linear lens distortions the points may not be uniformly spaced in world coordinates.
gridSize
A 1-by-2 integer matrix that contains the number of cells in the grid (width, height).

Different ways of positioning the grid.

Enumerator
FitInImage 

Make sure each cell fits in the image completely. If the size of the image is not a multiple of gridSpacing, leave equal top/bottom and left/right margins. If the input image is smaller than gridSpacing, this technique produces an empty set of points.

CoverWholeImage 

Make sure every pixel in the image is in one of the cells. If the size of the image is not a multiple of gridSpacing, the top/bottom and left/right cells exceed image boundaries by an equal amount.