Tidy
This commit is contained in:
parent
8fd0ec5dc6
commit
1ffb2c9110
|
@ -10,9 +10,10 @@ import colour
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def srgb_to_linear_array(a: np.ndarray, gamma=2.4) -> np.ndarray:
|
def srgb_to_linear_rgb_array(a: np.ndarray, gamma=2.4) -> np.ndarray:
|
||||||
return np.where(a <= 0.04045, a / 12.92, ((a + 0.055) / 1.055) ** gamma)
|
return np.where(a <= 0.04045, a / 12.92, ((a + 0.055) / 1.055) ** gamma)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Precomputing conversion matrix from 24-bit RGB to CAM16UCS colour "
|
print("Precomputing conversion matrix from 24-bit RGB to CAM16UCS colour "
|
||||||
"space")
|
"space")
|
||||||
|
@ -47,7 +48,7 @@ def main():
|
||||||
# //gs RGB values use gamma-corrected Rec.601 RGB colour space. We need to
|
# //gs RGB values use gamma-corrected Rec.601 RGB colour space. We need to
|
||||||
# convert to Rec.709 RGB as preparation for converting to CAM16UCS. We
|
# convert to Rec.709 RGB as preparation for converting to CAM16UCS. We
|
||||||
# do this via the YCbCr intermediate color model.
|
# do this via the YCbCr intermediate color model.
|
||||||
rgb12_iigs = np.clip(srgb_to_linear_array(
|
rgb12_iigs = np.clip(srgb_to_linear_rgb_array(
|
||||||
np.clip(colour.YCbCr_to_RGB(
|
np.clip(colour.YCbCr_to_RGB(
|
||||||
colour.RGB_to_YCbCr(
|
colour.RGB_to_YCbCr(
|
||||||
all_rgb12, K=colour.WEIGHTS_YCBCR[
|
all_rgb12, K=colour.WEIGHTS_YCBCR[
|
||||||
|
@ -62,5 +63,6 @@ def main():
|
||||||
np.save("data/rgb12_iigs_to_cam16ucs.npy", rgb12_iigs_to_cam16ucs)
|
np.save("data/rgb12_iigs_to_cam16ucs.npy", rgb12_iigs_to_cam16ucs)
|
||||||
del rgb12_iigs_to_cam16ucs
|
del rgb12_iigs_to_cam16ucs
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue