You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
770 B
Python

#!/usr/bin/env python3
import pyvips
import sys
print(sys.argv)
image = pyvips.Image.new_from_file(sys.argv[1], access="random")
# T = [
# 0.418385,
# -0.064912,
# 1.11204e-12,
# -1.07285e-16,
# 0.407118,
# 1.85136e-13,
# -0.000143964,
# -0.0000155811,
# ]
# T = [
# 2.39014,
# 0.381091,
# -5.07071e-13,
# 8.09745e-16,
# 2.45629,
# -1.95474e-12,
# 0.000344095,
# 0.0000931351,
# ]
T = list(map(float, sys.argv[2].split(",")))
i = pyvips.Image.xyz(image.width, image.height)
x = (i[0] * T[0] + i[1] * T[1] + T[2]) / (i[0] * T[6] + i[1] * T[7] + 1)
y = (i[0] * T[2] + i[1] * T[4] + T[5]) / (i[0] * T[6] + i[1] * T[7] + 1)
m = x.bandjoin(y)
image = image.mapim(m)
image.write_to_file(sys.argv[3])