ColorSchemes.jl icon indicating copy to clipboard operation
ColorSchemes.jl copied to clipboard

Ct scan greys

Open jakubMitura14 opened this issue 4 years ago • 2 comments
trafficstars

Hello I am trying to create colorscheme that I want to use in the heatmap of makie for now I use greys and It works quite well but

I would like to implement windows so pixels below given value a should be black all above given value b should be white different shades of grey for all values between a and b and proportional to those values

How to achieve this?

Thank you for help!

Below What Is already achieved but without windows

image

jakubMitura14 avatar May 29 '21 06:05 jakubMitura14

Hi Jakub! Assuming you can pass in normalised values from 0 to 1 in Makie, you can do this with ColorSchemeTools.jl:

using ColorSchemes, ColorSchemeTools

function f(n, a, b)
    if n < a
        return 0
    elseif n > b
        return 1
    else
        return ColorSchemes.remap(n, a, b, 0, 1)
    end
end

a = 0.3
b = 0.8

newscheme = make_colorscheme(n -> f(n, a, b), n -> f(n, a, b), n -> f(n, a, b), 
    length=100,
    category = " ... ",
    notes    = " ... ")
Screenshot 2021-05-29 at 09 27 45

cormullion avatar May 29 '21 08:05 cormullion

Thanks !

jakubMitura14 avatar May 30 '21 15:05 jakubMitura14