# Colorizing a UInt8 matrix

**URL:** <https://discourse.julialang.org/t/colorizing-a-uint8-matrix/99158>\
**Category:** New to Julia\
**Tags:** colors, map\
**Created:** [May 20, 2023, 10:31am UTC](https://discourse.julialang.org/t/colorizing-a-uint8-matrix/99158 "2023-05-20T10:31:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [May 20, 2023, 10:55am UTC](https://discourse.julialang.org/t/colorizing-a-uint8-matrix/99158/2 "2023-05-20T10:55:48Z")

</div>

```julia
julia> using ImageCore, IndirectArrays

julia> colormap = zeros(RGB{N0f8}, 0:255);

julia> colormap[[0,1,2,3,4,0xfd,0xfe,0xff]] = [colorant"red", colorant"white", colorant"light gray", colorant"aqua", colorant"blue", colorant"gold", colorant"black", colorant"red"]
8-element Array{RGB{N0f8},1} with eltype RGB{N0f8}:
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,1.0,1.0)
 RGB{N0f8}(0.827,0.827,0.827)
 RGB{N0f8}(0.0,1.0,1.0)
 RGB{N0f8}(0.0,0.0,1.0)
 RGB{N0f8}(1.0,0.843,0.0)
 RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)

julia> img = IndirectArray(mymatrix, colormap);

```

should do the trick.

---

_[View the full topic](https://discourse.julialang.org/t/colorizing-a-uint8-matrix/99158)._
