Hi, I want to change array of Floats(Calculated Values of Magnetic Induction) into colormap in cimgui app. I want something like this(matlab colormaps). I wrote simillar question here.

I just thinked how to achieve this in hard way(no package, just clear code and algorithm) and I knew that I should find the highest and lowest value in my table. For the highest and lowest I should assign some two extreme values and with some linear algorithm assign the mid values to the colors. For example in HSVA format I could assign H=170 for lowest value and H=0 for highest value(S, V and A would be constant) and for mid values assign appropriate colors and assign them to new array however i am sure that there are some ready-made solutions(like matlab colormaps). If you know how to achieve that I would be grateful.

# Change float into color or change array of Floats into colormap

If you want to create an array with RGB color entries from a scalar-valued array, look at ImageCore’s `scalesigned`

and `colorsigned`

. Demo, assuming the min value is -0.2 and the max value is 1.0:

```
julia> f = colorsigned() ∘ scalesigned(-0.2, 0, 1.0)
#56 (generic function with 1 method)
julia> f(-0.2)
RGB{N0f8}(0.0,1.0,0.0)
julia> f(0)
RGB{N0f8}(1.0,1.0,1.0)
julia> f(1)
RGB{N0f8}(1.0,0.0,1.0)
julia> f.(A) # map the values of array A into colors
```

4 Likes

Thanks, that’s what I looked for. I’ll go through documentation to find other colourways(I assume that `colorsigned()`

takes default colourway that is from white to pink).