mirror of
https://github.com/KrisKennaway/ii-pix.git
synced 2025-01-18 16:30:38 +00:00
Optimize memory a bit
This commit is contained in:
parent
4fbb0faf84
commit
0f1ec6f6f2
@ -1,5 +1,6 @@
|
||||
"""Precompute CIE2000 perceptual colour distance matrices.
|
||||
|
||||
XXX
|
||||
The matrix of delta-E values is computed for all pairs of 24-bit RGB values,
|
||||
and Apple II target palette values. This is written out as a file that is
|
||||
mmapped at runtime for efficient access. For a 16-colour target palette this
|
||||
@ -14,16 +15,18 @@ def main():
|
||||
print("Precomputing conversion matrix from RGB to CAM16UCS colour space")
|
||||
|
||||
# Compute matrix of all 24-bit RGB values, normalized to 0..1 range
|
||||
bits24 = np.arange(2 ** 24).reshape(-1, 1)
|
||||
all_rgb = (np.concatenate(
|
||||
bits24 = np.arange(2 ** 24, dtype=np.uint32).reshape(-1, 1)
|
||||
all_rgb = np.concatenate(
|
||||
[bits24 >> 16 & 0xff, bits24 >> 8 & 0xff, bits24 & 0xff],
|
||||
axis=1) / 255).astype(np.float32)
|
||||
axis=1).astype(np.float32) / 255
|
||||
del bits24
|
||||
|
||||
with colour.utilities.suppress_warnings(colour_usage_warnings=True):
|
||||
# Compute matrix of corresponding CAM16UCS colour values, indexed
|
||||
# by 24-bit RGB value
|
||||
all_cam16 = colour.convert(all_rgb, "RGB", "CAM16UCS").astype(
|
||||
np.float32)
|
||||
del all_rgb
|
||||
np.save("data/rgb_to_cam16ucs.npy", all_cam16)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user