Image.Squares#
- classmethod Image.Squares(number: int, *, size: int | Sequence[int] | None = None, fg: Any = 1, bg: Any = 0, dtype: Dtype | None = None, colororder: str | None = None, like=None) Self[source]#
Create image containing grid of squares
- Parameters:
number (int) – number of squares horizontally and vertically
size (int or 2-tuple, optional) – image size; scalar gives a square image, 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 or NumPy dtype, optional) – NumPy datatype, defaults to ‘uint8’
colororder (str or None, optional) – color plane names for the output image, defaults to None
like (
Imageor None, optional) – template image supplying defaultsize,dtypeandcolororderwhen those are not given explicitly
- Returns:
grid of squares
- Return type:
The image background is set to
bgand the circles are filled withfg.Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Squares(2, size=14, bg=1, fg=9) >>> img.print() 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 1 1 9 9 9 9 1 1 1 1 9 9 9 9 1 1 9 9 9 9 1 1 1 1 9 9 9 9 1 1 9 9 9 9 1 1 1 1 9 9 9 9 1 1 9 9 9 9 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 1 1 9 9 9 9 1 1 9 9 9 9 1 1 1 1 9 9 9 9 1 1 9 9 9 9 1 1 1 1 9 9 9 9 1 1 9 9 9 9 1 1 1 1 9 9 9 9 1 1 9 9 9 9 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
numberequal to 1, 2 and 8:(
Source code,png,hires.png,pdf)
Note
Image is square.