Exemple #1
0
def _iter_make_linear(jab):

    # Linearize a' and b' changes
    jab1 = cmu.make_linear(np.copy(jab))

    # Convert J'a'b' values to RGB values and clip
    rgb1 = np.clip(cmu.convert(jab1, CSPACE2, CSPACE1), 0, 1)

    # Convert RGB to CVD RGB space
    rgb2 = get_cvd(rgb1)

    # Bring back to to J'a'b'
    jab2 = cmu.convert(rgb2, CSPACE1, CSPACE2)

    # Force to have same J' as original J'a'b' array
    jab2[0, :] = jab1[0, :]

    return jab2
Exemple #2
0
FLABEL = 20
FAX = 16

#%% Get iteration data
cmap = 'viridis'  # The optimized version of this colormap is cividis!

# Get original RGB/Jab
t = time()
rgb1, jab1 = cmu.get_rgb_jab(cmap)

# Get CVD RGB/Jab
rgb2, jab2 = cmu.get_rgb_jab(cvu.get_cvd(rgb1, severity=100))

# Make perceptual deltas (for a' vs. b') straight
# Need to set a and b before straightening J
jab3 = cmu.make_linear(jab2)
rgb3 = cmu.convert(jab3, cmu.CSPACE2, cmu.CSPACE1)

# Linearize J'
jab4, jab5 = cmu.correct_J(
    jab3)  # This will create a figure showing the J bounds
if jab4 is not None:
    rgb4 = cmu.convert(jab4, cmu.CSPACE2, cmu.CSPACE1)
    rgb4 = np.clip(rgb4, 0, 1)
if jab5 is not None:
    rgb5 = cmu.convert(jab5, cmu.CSPACE2, cmu.CSPACE1)
    rgb5 = np.clip(rgb5, 0, 1)

#%% Figure: Iterations for optimization

fig = plt.figure(figsize=(25, 12), dpi=500)
Exemple #3
0
import numpy as np

import cmaputil as cmu
import cmaputil.cvdutil as cvu

# Globals
FLABEL = 20
FAX = 16

# Input colormap name
cmap = 'viridis'

# Optimize
rgb1, jab1 = cmu.get_rgb_jab(cmap)  # Original colormap
rgb2, jab2 = cmu.get_rgb_jab(cvu.get_cvd(rgb1))  # CVD colormap
jab3 = cmu.make_linear(jab2)  # Uniformize hue (a' vs. b')
_, jab4 = cmu.correct_J(jab3)  # Linearize J'

# Convert back to sRGB
rgb4 = cmu.convert(jab4, cmu.CSPACE2, cmu.CSPACE1)
rgb4 = np.clip(rgb4, 0, 1)

# Resimulate CVD in case corrections took the map outside CVD-safe space
rgb4 = cvu.get_cvd(rgb4)

#%% Creat CDPS plots (shown in Fig 1 and 5 of the paper)

# Import test data
img_name = 'example_nanosims_image.txt'  # Image used for paper
img = np.loadtxt(img_name)[45:, :-45]  # Make square
high = 3