Browse Source

save sorts for color chart

plotting-unify
Michael Pilosov, PhD 9 months ago
parent
commit
9430e0fcd3
  1. 11
      scripts/sortcolor.py

11
scripts/sortcolor.py

@ -81,6 +81,10 @@ def peano_curve(n):
return curve
PDIR = f"scripts"
Path(PDIR).mkdir(parents=True, exist_ok=True)
file_path = f"{PDIR}/{KIND}_sorted_indices.npy"
if KIND in ("lex", "alpha", "abc"):
preds = np.array(colors)
@ -88,7 +92,6 @@ elif KIND == "umap":
PDIR = f"scripts/{KIND}-prod"
Path(PDIR).mkdir(parents=True, exist_ok=True)
file_path = f"{PDIR}/{SEED:06d}.npy"
if Path(file_path).exists():
print(f"Loading {file_path}")
preds = np.load(file_path)
@ -112,9 +115,6 @@ elif KIND == "umap":
preds = embedding[:, 0]
del reducer, embedding
# Save the sorted indices to disk
print(f"Saving {file_path}")
np.save(file_path, preds.ravel())
elif KIND in ("cielab", "lab", "ciede2000"):
from skimage.color import deltaE_ciede2000, rgb2lab
@ -148,6 +148,9 @@ elif KIND == "hsv":
else:
raise ValueError(f"Unknown kind: {KIND}")
# Save the sorted indices to disk
print(f"Saving {file_path}")
np.save(file_path, preds.ravel())
# Sort colors by the 1D representation
sorted_indices = np.argsort(preds)

Loading…
Cancel
Save