Main Content

checkerboard

Create checkerboard image

Description

example

I= checkerboardcreates an 8-by-8 square checkerboard image that has four identifiable corners. The checkerboard pattern is made up of tiles. Each tile contains four squares, each with a default of 10 pixels per side. The light squares on the left half of the checkerboard are white. The light squares on the right half of the checkerboard are gray.

TILE = [DARK LIGHT; LIGHT DARK]

example

I= checkerboard(n)creates an 8-by-8 square checkerboard image where each square hasnpixels per side.

example

I= checkerboard(n,p,q)creates a rectangular checkerboard image wherepspecifies the number of rows of tiles andqspecifies the number of columns of tiles. If you omitq, the number of columns defaults topand the checkerboard is square. Each square hasnpixels per side.

Examples

全部折叠

Create a checkerboard where the side of every square is 20 pixels in length.

I = checkerboard(20);

Display the checkerboard.

imshow(I)

Figure contains an axes object. The axes object contains an object of type image.

Create a rectangular checkerboard that is 2 tiles high and 3 tiles wide. The side of every square is 20 pixels in length.

J = checkerboard(20,2,3);

Display the checkerboard.

figure imshow(J)

Figure contains an axes object. The axes object contains an object of type image.

Create a black and white checkerboard with the default tile size and the default number of rows and columns.

K = (checkerboard > 0.5);

Display the checkerboard.

figure imshow(K)

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

全部折叠

Side length in pixels of each square in the checkerboard pattern, specified as a positive integer.

Number of rows of tiles in the checkerboard pattern, specified as a positive integer. Since there are four squares per tile, there are2*p行方格的棋盘。

Number of columns of tiles in the checkerboard pattern, specified as a positive integer. If you omitq, the value defaults topand the checkerboard is square. Since there are four squares per tile, there are2*qcolumns of squares in the checkerboard.

Output Arguments

全部折叠

Rectangular image with a checkerboard pattern, returned as a 2-D numeric array. The light squares on the left half of the checkerboard are white. The light squares on the right half of the checkerboard are gray.

Data Types:double

Version History

Introduced before R2006a

See Also

|