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

**URL:** <https://discourse.julialang.org/t/how-to-represent-binary-array-slot-occupied-1-slot-open-0-in-the-form-of-colored-squares/29631>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [October 8, 2019, 2:43am UTC](https://discourse.julialang.org/t/how-to-represent-binary-array-slot-occupied-1-slot-open-0-in-the-form-of-colored-squares/29631 "2019-10-08T02:43:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amoghb13](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amoghb13](https://discourse.julialang.org/u/amoghb13)\
**Post date:** [October 8, 2019, 2:43am UTC](https://discourse.julialang.org/t/how-to-represent-binary-array-slot-occupied-1-slot-open-0-in-the-form-of-colored-squares/29631/1 "2019-10-08T02:43:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 8, 2019, 7:34am UTC](https://discourse.julialang.org/t/how-to-represent-binary-array-slot-occupied-1-slot-open-0-in-the-form-of-colored-squares/29631/2 "2019-10-08T07:34:38Z")

</div>

```julia
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](https://juliaimages.org/latest/).

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