Function File: checkerboard ()
Function File: checkerboard (side)
Function File: checkerboard (side, size)
Function File: checkerboard (side, M, N)
Function File: checkerboard (side, M, N, P, …)

Create checkerboard.

The checkerboard is created by repeating a tile pattern and creating a block matrix of size size, or MxN. The tile pattern itself is made of four squares of side pixels wide. Note how the number of squares is twice of size.

The tile pattern is white on black on the right side, and grey on black on the left side of the matrix.

At the simplest case, a 2 by 2 pattern with squares of 1 pixel side.

checkerboard (1, [2 2])
⇒
   0.0   1.0   0.0   0.7
   1.0   0.0   0.7   0.0
   0.0   1.0   0.0   0.7
   1.0   0.0   0.7   0.0

Defaults to 4x4 tiles 10 pixels wide.

N-Dimensional checkerboards are supported with size of any length or specifying dimension length arguments, i.e., M, N, P, ….

See also: ndgrid, repmat.

Demonstration 1

The following code

 ## Simplest case, default checkerboard size:
 ##     8 by 8 checkerboard, with squares 10 pixel wide
 board = checkerboard ();
 imshow (board)

Produces the following figure

Figure 1

Demonstration 2

The following code

 ## Simplest case, default checkerboard size:
 ##     8 by 16 checkerboard, with squares 5 pixel wide
 board = checkerboard (5, 4, 8);
 imshow (board)

Produces the following figure

Figure 1

Package: image