コード例 #1
0
def iFSHT(coeffs,
          envmap_size,
          envmap_format='latlong',
          reduction_type='right'):
    if reduction_type != 'right':
        raise NotImplemented()

    degrees = int(np.sqrt(8 * coeffs.shape[0]) / 2. - 1)

    ch = coeffs.shape[1]
    envmap = EnvironmentMap(np.zeros((envmap_size, envmap_size * 2, ch)),
                            envmap_format)
    envmap.data = envmap.data.astype(np.complex128)

    P, _ = _getP(envmap, degrees)

    i = 0
    for l in tqdm(range(degrees + 1)):
        for m in range(0, l + 1):
            for c in range(ch):
                envmap.data[:, m, c] += P[:, i] * coeffs[i, c]
            i += 1

    #import pdb; pdb.set_trace()

    envmap.data = np.fft.ifft(envmap.data, axis=1).real

    return envmap
コード例 #2
0
def inverseSphericalHarmonicTransform(coeffs,
                                      envmap_height=512,
                                      format_='latlong',
                                      reduction_type='right'):
    """
    Recovers an EnvironmentMap from a list of coefficients.
    """
    degrees = np.asscalar(np.sqrt(coeffs.shape[0]).astype('int')) - 1

    coeffs = addRedundantCoeffs(coeffs, reduction_type)[..., np.newaxis]

    ch = coeffs.shape[1] if len(coeffs.shape) > 0 else 1
    retval = EnvironmentMap(envmap_height, format_)
    retval.data = np.zeros((retval.data.shape[0], retval.data.shape[1], ch),
                           dtype=np.float32)

    x, y, z, valid = retval.worldCoordinates()
    theta = np.arctan2(x, -z)
    phi = np.arccos(y)

    for l in range(degrees + 1):
        for col, m in enumerate(range(-l, l + 1)):
            Y = sph_harm(m, l, theta, phi)
            for c in range(ch):
                retval.data[..., c] += (coeffs[l**2 + col, c] * Y).real

    return retval
コード例 #3
0
 def __call__(self, sample):
     from envmap import EnvironmentMap
     image = EnvironmentMap(64, 'LatLong')
     image.data = sample
     rotation = self.random_direction()
     img_hdr = image.rotate('DCM', rotation).data.astype('float32')
     sample = img_hdr
     return sample