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.
39 lines
684 B
Python
39 lines
684 B
Python
4 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
import pyvips
|
||
|
|
||
|
image = pyvips.Image.new_from_file("demo.jpg", 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,
|
||
|
]
|
||
|
|
||
|
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("./output_pyvips.jpg")
|