Initial commit

master
Kuba Orlik 4 years ago
commit 0152285894

2
.gitignore vendored

@ -0,0 +1,2 @@
/output_im.jpg
/output_pyvips.jpg

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
time python ./main.py
time convert demo.jpg -virtual-pixel Transparent -distort PerspectiveProjection '0.418385,-0.064912,1.11204e-12,-1.07285e-16,0.407118,1.85136e-13,-0.000143964,-0.0000155811' output_im.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

@ -0,0 +1,38 @@
#!/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")
Loading…
Cancel
Save