how to create black and white checkerboards with different number of squares

1 Ansicht (letzte 30 Tage)
How can I create black and white checkerboard with different number of squares, for example, 2 squares, 4, 8, 16,32....
with the inbuilt checkerboard function, there is grey squares, which is undesirable

Akzeptierte Antwort

Adam Danz
Adam Danz am 18 Apr. 2019
Bearbeitet: Adam Danz am 23 Apr. 2019
The output of checkerboard() contains normalized values where 0 represents black, 1 represents white, and values between represent shades of gray. Just replace the values greater than 0 with 1.
I = checkerboard(20);
I(I>0) = 1;
imshow(I)
  3 Kommentare
Jimmy Liang
Jimmy Liang am 25 Apr. 2019
And do you know can I grant values in the squares. for example, white squares represent a value(i.e. 10), black squares represent another value (i.e. 100). thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by