machinevisiontoolbox.Image.Squares

classmethod Image.Squares(number, size=256, fg=1, bg=0, dtype='uint8')

Create image containing grid of squares

Parameters:
  • number (int) – number of squares horizontally and vertically

  • size (int, optional) – image width and height, defaults to 256

  • fg (int, float, optional) – pixel value of the squares, defaults to 1

  • bg (int, optional) – pixel value of the background, defaults to 0

  • dtype (str, optional) – NumPy datatype, defaults to ‘uint8’

Returns:

grid of squares

Return type:

Image

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Squares(2, 14, bg=1, fg=9)
>>> img.A
array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 9, 9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], dtype=uint8)
Note:

Image is square.