Fixes for python 3.10 and/or latest dependency versions

This commit is contained in:
kris 2023-01-21 17:29:06 +00:00
parent 7b8b6bc12b
commit 629104b933
4 changed files with 18 additions and 13 deletions

View File

@ -11,7 +11,7 @@ class DitherPattern:
class NoDither(DitherPattern):
"""No dithering."""
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)
@ -20,7 +20,7 @@ class FloydSteinbergDither(DitherPattern):
# 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)
@ -31,7 +31,7 @@ class FloydSteinbergDither2(DitherPattern):
PATTERN = np.array(
((0, 0, 0, 0, 0, 7),
(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)

View File

@ -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)
# TODO: precompute this conversion matrix since it's static. This accounts for about 10% of the CPU time here.
rgb12_iigs = np.clip(
# Convert to Rec.601 R'G'B'
colour.YCbCr_to_RGB(
# Gamma correct and convert Rec.709 R'G'B' to YCbCr
colour.RGB_to_YCbCr(
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
rgb12_iigs = np.ascontiguousarray(
np.clip(
# Convert to Rec.601 R'G'B'
colour.YCbCr_to_RGB(
# Gamma correct and convert Rec.709 R'G'B' to YCbCr
colour.RGB_to_YCbCr(
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)
# Wrapper around _convert_cam16ucs_to_rgb12_iigs to allow calling from python while retaining fast path for cython

View File

@ -30,7 +30,8 @@ def main():
rgb24_to_cam16ucs = colour.convert(all_rgb24, "RGB", "CAM16UCS").astype(
np.float32)
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
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, "RGB", "CAM16UCS").astype(np.float32)
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

View File

@ -161,7 +161,8 @@ class DHGRScreen:
# Apply effect of saturation
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
yuv_to_rgb = np.matmul(np.array(
((1, 0, 0), (0, np.cos(hue), np.sin(hue)), (0, -np.sin(hue),