-
Notifications
You must be signed in to change notification settings - Fork 2
/
mapping.py
37 lines (28 loc) · 1.12 KB
/
mapping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pga import PGA
from aep import AEP
from cosine_normals import Spherical
import numpy as np
class ImageMapper(object):
def __init__(self, mapper):
self._mapper = mapper
def logmap(self, tangent_vectors):
vectors = tangent_vectors.as_vector(keep_channels=True)
logmap_vectors = self._mapper.logmap(vectors)
return tangent_vectors.from_vector(np.squeeze(logmap_vectors),
n_channels=logmap_vectors.shape[2])
def expmap(self, sd_vectors):
vectors = sd_vectors.as_vector(keep_channels=True)
expmap_vectors = self._mapper.expmap(vectors)
return sd_vectors.from_vector(np.squeeze(expmap_vectors),
n_channels=expmap_vectors.shape[2])
class IdentityMapper(object):
def logmap(self, sd_vectors):
if sd_vectors.ndim == 2:
return sd_vectors[None, ...]
else:
return sd_vectors
def expmap(self, tangent_vectors):
if tangent_vectors.ndim == 2:
return tangent_vectors[None, ...]
else:
return tangent_vectors