Skip to content

Commit 564fd50

Browse files
author
Keim, Stefan
committed
idx creation improved
1 parent 74b5688 commit 564fd50

4 files changed

Lines changed: 35 additions & 28 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ MANIFEST
5555
docs
5656
htmlcov
5757
tests/in
58-
tests/out
58+
tests/out
59+
src/kubi/kubi_.py

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
=========
44

5+
Version 0.1.2
6+
===========
7+
8+
- performance of idx creation improved
9+
- Basic tests passed (97% coverage | 194run | 0 missing | 4 excluded | 8 partial)
10+
511
Version 0.1.1
612
===========
713

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ Marzipano.ImageUrlSource.fromString("<some_path>/dstfile_{f}/{z}/{y}/{x}.jpg");
6767

6868
| face size | 1024px | 2048px | 4096px |
6969
| ---| --- | --- | --- |
70-
| kubi | 0.9s | 1.7s | 4.9s |
71-
| [py360convert](https://pypi.org/project/py360convert/) | 2.5s | 8.7s | 33.0s |
70+
| kubi | 0.9s | 1.6s | 4.7s |
71+
| [py360convert](https://pypi.org/project/py360convert/) | 2.6s | 8.6s | 32.2s |
7272
| *any others ?* | - | - | - |
7373

7474
### single input file - tiled output
@@ -77,8 +77,8 @@ Marzipano.ImageUrlSource.fromString("<some_path>/dstfile_{f}/{z}/{y}/{x}.jpg");
7777

7878
| face size | 1024px | 2048px | 4096px |
7979
| ---| --- | --- | --- |
80-
| kubi | 0.9s | 1.4s | 3.5s |
81-
| [panorama_windows.exe](https://github.com/blackironj/panorama) | 1.4s | 4.4s | 16.8s |
80+
| kubi | 0.9s | 1.3s | 3.1s |
81+
| [panorama_windows.exe](https://github.com/blackironj/panorama) | 1.5s | 4.7s | 16.9s |
8282
| *any others ?* | - | - | - |
8383

8484
### multiple input files

src/kubi/kubi.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
# `from kubi.kubi import kubi`,
3232
# when using this Python module as a library.
3333

34-
3534
def kubi(args):
3635

3736
if IsWin:
@@ -70,32 +69,33 @@ def kubi(args):
7069
elif args.transform == "otc": # M.Zucker & Y.Higashi (2018): Cube-to-sphere Projections for Procedural Texturing and Beyond
7170
ls = np.tan(ls * 0.8687) / np.tan(0.8687)
7271

73-
xv,yv = np.meshgrid(ls, ls)
74-
75-
xv2 = xv ** 2
76-
yv2 = yv ** 2
77-
78-
idx = np.stack([
79-
np.arctan(xv), #tha0
80-
np.arctan2(yv, np.sqrt(1 + xv2)), #phi0
81-
np.arctan2(xv, yv), #tha1
82-
np.arctan2(1, np.sqrt(yv2 + xv2)) #phi1
83-
], axis=-1)
84-
85-
### end of numpy
72+
xv,yv = np.meshgrid(ls, ls, copy=False)
8673

87-
ls = xv = yv = xv2 = yv2 = None
88-
89-
idx = pyvips.Image.new_from_memory(idx.reshape(size**2 * 4), size, size, 4, 'float') / (pi/2)
74+
x0 = np.arctan(xv)
75+
y0 = np.arctan2(yv, np.hypot(1,xv))
76+
x1 = np.arctan2(xv, yv)
77+
y1 = np.arctan(np.hypot(yv,xv))
78+
79+
ls = xv = yv = None
80+
81+
piot = pi/2
82+
83+
x0 = pyvips.Image.new_from_memory(x0.ravel(), size, size, 1, 'float') / piot
84+
y0 = pyvips.Image.new_from_memory(y0.ravel(), size, size, 1, 'float') / piot
85+
x1 = pyvips.Image.new_from_memory(x1.ravel(), size, size, 1, 'float') / piot
86+
y1 = pyvips.Image.new_from_memory(y1.ravel(), size, size, 1, 'float') / piot
87+
88+
### end of numpy
9089

9190
idx = [
92-
pyvips.Image.bandjoin(idx[0]+3,idx[1]+1),
93-
pyvips.Image.bandjoin(idx[0]+1,idx[1]+1),
94-
pyvips.Image.bandjoin((idx[2]-2)%4,1-idx[3]),
95-
pyvips.Image.bandjoin((4-idx[2])%4,1+idx[3]),
96-
pyvips.Image.bandjoin(idx[0]+2,idx[1]+1),
97-
pyvips.Image.bandjoin(idx[0]%4,idx[1]+1),
91+
pyvips.Image.bandjoin(x0+3,y0+1),
92+
pyvips.Image.bandjoin(x0+1,y0+1),
93+
pyvips.Image.bandjoin((x1-2)%4,y1),
94+
pyvips.Image.bandjoin((4-x1)%4,2-y1),
95+
pyvips.Image.bandjoin(x0+2,y0+1),
96+
pyvips.Image.bandjoin(x0%4,y0+1),
9897
]
98+
9999

100100
if args.layout is None or args.layout in ("column","row"):
101101
if args.inverse is not None:

0 commit comments

Comments
 (0)