Image.Chequerboard#

classmethod Image.Chequerboard(square: int = 32, *, size: int | Sequence[int] | None = None, dtype: Dtype | None = None, colororder: str | None = None, like=None) Self[source]#

Create chequerboard pattern

Parameters:
  • size (int or 2-tuple, optional) – image size, width x height, defaults to 256x256

  • square (int, optional) – cell dimension in pixels, defaults to 32

  • dtype (str or NumPy dtype, optional) – image data type, defaults to “uint8”

  • colororder (str or None, optional) – color plane names for the output image, defaults to None

  • like (Image or None, optional) – template image supplying default size, dtype and colororder when those are not given explicitly

Returns:

chequerboard pattern

Return type:

Image

Create a chquerboard pattern with black and white square cells of side length square.

The pixel values within the cells are:

  • float image: black squares 0.0, white squares 1.0

  • int image: black squares 0, white squares maximum positive value of the integer type

Example:

>>> from machinevisiontoolbox import Image
>>> Image.Chequerboard(square=2, size=8).print()
   255 255   0   0 255 255   0   0
   255 255   0   0 255 255   0   0
     0   0 255 255   0   0 255 255
     0   0 255 255   0   0 255 255
   255 255   0   0 255 255   0   0
   255 255   0   0 255 255   0   0
     0   0 255 255   0   0 255 255
     0   0 255 255   0   0 255 255

square equal to 16, 32 and 64:

(Source code, png, hires.png, pdf)

../_images/machinevisiontoolbox-Image-Chequerboard-1.png

Note

There is no check for size being an integral multiple of square so the last row and column may be of different size to the others.