Fixes for python 3.10 and/or latest dependency versions
This commit is contained in:
parent
7b8b6bc12b
commit
629104b933
|
@ -11,7 +11,7 @@ class DitherPattern:
|
||||||
class NoDither(DitherPattern):
|
class NoDither(DitherPattern):
|
||||||
"""No dithering."""
|
"""No dithering."""
|
||||||
PATTERN = np.array(((0, 0), (0, 0)),
|
PATTERN = np.array(((0, 0), (0, 0)),
|
||||||
dtype=np.float32).reshape(2, 2) / np.float(16)
|
dtype=np.float32).reshape(2, 2) / np.float32(16)
|
||||||
ORIGIN = (0, 1)
|
ORIGIN = (0, 1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class FloydSteinbergDither(DitherPattern):
|
||||||
# 0 * 7
|
# 0 * 7
|
||||||
# 3 5 1
|
# 3 5 1
|
||||||
PATTERN = np.array(((0, 0, 7), (3, 5, 1)),
|
PATTERN = np.array(((0, 0, 7), (3, 5, 1)),
|
||||||
dtype=np.float32).reshape(2, 3) / np.float(16)
|
dtype=np.float32).reshape(2, 3) / np.float32(16)
|
||||||
ORIGIN = (0, 1)
|
ORIGIN = (0, 1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class FloydSteinbergDither2(DitherPattern):
|
||||||
PATTERN = np.array(
|
PATTERN = np.array(
|
||||||
((0, 0, 0, 0, 0, 7),
|
((0, 0, 0, 0, 0, 7),
|
||||||
(3, 5, 1, 0, 0, 0)),
|
(3, 5, 1, 0, 0, 0)),
|
||||||
dtype=np.float32).reshape(2, 6) / np.float(16)
|
dtype=np.float32).reshape(2, 6) / np.float32(16)
|
||||||
ORIGIN = (0, 2)
|
ORIGIN = (0, 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -315,13 +315,15 @@ cdef (unsigned char)[:, ::1] _convert_cam16ucs_to_rgb12_iigs(float[:, ::1] point
|
||||||
rgb = colour.convert(point_cam, "CAM16UCS", "RGB").astype(np.float32)
|
rgb = colour.convert(point_cam, "CAM16UCS", "RGB").astype(np.float32)
|
||||||
|
|
||||||
# TODO: precompute this conversion matrix since it's static. This accounts for about 10% of the CPU time here.
|
# TODO: precompute this conversion matrix since it's static. This accounts for about 10% of the CPU time here.
|
||||||
rgb12_iigs = np.clip(
|
rgb12_iigs = np.ascontiguousarray(
|
||||||
# Convert to Rec.601 R'G'B'
|
np.clip(
|
||||||
colour.YCbCr_to_RGB(
|
# Convert to Rec.601 R'G'B'
|
||||||
# Gamma correct and convert Rec.709 R'G'B' to YCbCr
|
colour.YCbCr_to_RGB(
|
||||||
colour.RGB_to_YCbCr(
|
# Gamma correct and convert Rec.709 R'G'B' to YCbCr
|
||||||
linear_to_srgb_array(rgb), K=colour.WEIGHTS_YCBCR['ITU-R BT.709']),
|
colour.RGB_to_YCbCr(
|
||||||
K=colour.WEIGHTS_YCBCR['ITU-R BT.601']), 0, 1).astype(np.float32) * 15
|
linear_to_srgb_array(rgb), K=colour.WEIGHTS_YCBCR['ITU-R BT.709']),
|
||||||
|
K=colour.WEIGHTS_YCBCR['ITU-R BT.601']), 0, 1)
|
||||||
|
).astype(np.float32) * 15
|
||||||
return np.round(rgb12_iigs).astype(np.uint8)
|
return np.round(rgb12_iigs).astype(np.uint8)
|
||||||
|
|
||||||
# Wrapper around _convert_cam16ucs_to_rgb12_iigs to allow calling from python while retaining fast path for cython
|
# Wrapper around _convert_cam16ucs_to_rgb12_iigs to allow calling from python while retaining fast path for cython
|
||||||
|
|
|
@ -30,7 +30,8 @@ def main():
|
||||||
rgb24_to_cam16ucs = colour.convert(all_rgb24, "RGB", "CAM16UCS").astype(
|
rgb24_to_cam16ucs = colour.convert(all_rgb24, "RGB", "CAM16UCS").astype(
|
||||||
np.float32)
|
np.float32)
|
||||||
del all_rgb24
|
del all_rgb24
|
||||||
np.save("data/rgb24_to_cam16ucs.npy", rgb24_to_cam16ucs)
|
np.save("data/rgb24_to_cam16ucs.npy", np.ascontiguousarray(
|
||||||
|
rgb24_to_cam16ucs))
|
||||||
del rgb24_to_cam16ucs
|
del rgb24_to_cam16ucs
|
||||||
|
|
||||||
print("Precomputing conversion matrix from 12-bit //gs RGB to CAM16UCS "
|
print("Precomputing conversion matrix from 12-bit //gs RGB to CAM16UCS "
|
||||||
|
@ -60,7 +61,8 @@ def main():
|
||||||
rgb12_iigs_to_cam16ucs = colour.convert(
|
rgb12_iigs_to_cam16ucs = colour.convert(
|
||||||
rgb12_iigs, "RGB", "CAM16UCS").astype(np.float32)
|
rgb12_iigs, "RGB", "CAM16UCS").astype(np.float32)
|
||||||
del rgb12_iigs
|
del rgb12_iigs
|
||||||
np.save("data/rgb12_iigs_to_cam16ucs.npy", rgb12_iigs_to_cam16ucs)
|
np.save("data/rgb12_iigs_to_cam16ucs.npy", np.ascontiguousarray(
|
||||||
|
rgb12_iigs_to_cam16ucs))
|
||||||
del rgb12_iigs_to_cam16ucs
|
del rgb12_iigs_to_cam16ucs
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,8 @@ class DHGRScreen:
|
||||||
|
|
||||||
# Apply effect of saturation
|
# Apply effect of saturation
|
||||||
yuv_to_rgb = np.array(
|
yuv_to_rgb = np.array(
|
||||||
((1, 0, 0), (0, saturation, 0), (0, 0, saturation)), dtype=np.float)
|
((1, 0, 0), (0, saturation, 0), (0, 0, saturation)),
|
||||||
|
dtype=np.float32)
|
||||||
# Apply hue phase rotation
|
# Apply hue phase rotation
|
||||||
yuv_to_rgb = np.matmul(np.array(
|
yuv_to_rgb = np.matmul(np.array(
|
||||||
((1, 0, 0), (0, np.cos(hue), np.sin(hue)), (0, -np.sin(hue),
|
((1, 0, 0), (0, np.cos(hue), np.sin(hue)), (0, -np.sin(hue),
|
||||||
|
|
Loading…
Reference in New Issue