How to represent binary array (slot occupied = 1, slot open = 0) in the form of colored squares

Hi I want to represent a binary (0-1) array in the form of an image. E.g. if A[1,1] = 1, then square [1,1[ would be represented as black colored square otherwise it will be represented as white colored square if A[1,1] = 0.

Please tell me what packages to use and how code should be written

using Images, Random
Gray.(bitrand(10, 10))

If you’re using Juno or IJulia, this should just show up as an image. Or you can use ImageView. There are extensive docs at Home · JuliaImages.

Note that in Julia and every other language I know of, true = 1 = white and false = 0 = black.

1 Like