@moeddel
The colormap defined by complexColoring
is a modified version of the cmocean colormap, phase
. All cmocean colormaps, as well as matplotlib viridis
, plasma
, magma
, inferno
are perceptually uniform within the color space CAM02-UCS, NOT CIELab (Lab)!!!
Namely, if C is such a colormap, and x represents normalized data to be mapped to C, then the geometry of the 3d curve in the RGB color space
color(x)=(R(x), G(x), B(x))∈ C
doesn’t give any information on the quality of the considered colormap.
Converting the RGB color-space to the CAM02-UCS space, referenced to a system of cylindrical coordinates, (Lightness, Chroma, Hue), to the above curve corresponds the curve
x∈[0,1]-> (Lightnesss(x), Chroma(x), Hue(x))
in the latter space.
By definition, the colormap C is perceptually uniform in the CAM02-UCS space if the graph of the first component
x ∈[0,1]--> Lightness(x)
is linear.
The colormap ColorSchemes.phase
has a linear and constant Lightness (see the first image in the panel below).
Inside the function complexColoring
it is called the function
function normalizeGray(c::T,g=0.7) where {T<:Colorant}
cluv = Lab(c)
# test range
minG = Gray.(Lab(0,cluv.a,cluv.b)).val
maxG = Gray.(Lab(100,cluv.a,cluv.b)).val
if g < minG
g = minG
@warn "Normalization of gray value failed, g ≈ $(ceil(minG,digits=3)) is used. Use g >= $(ceil(minG,digits=3)) for a consistent normalization."
elseif g > maxG
g = maxG
@warn "Normalization of gray value failed, g ≈ $(floor(maxG,digits=3)) is used. Use g <= $(floor(maxG,digits=3)) for a consistent normalization."
end
l = find_zero(l->Gray.(Lab(l,cluv.a,cluv.b)).val-g, (0, 100))
return T(Lab(l,cluv.a,cluv.b))
end
which modifies the Lab components of a perceptually uniform colormap not in the CIELab space, but within the space CAM02-UCS. And this mixture of colorspaces transforms the phase colormap into one which is no more perceptually uniform.
In the panel below I included the plots of Lightness, Chroma and Hue of the initial ColorSchemes.phase (the colorful line representing its linear and constant lightness), the colorscheme obtained from phase by calling normalizeGray.
with g=0.35, respectively, g=0.7 (the default value). We notice that the lightness for the last two cases is not linear. Hence the last two colormaps are not perceptually uniform, and the (de)saturation can deviate further their lightness from linearity.