raise NotImplemented() elif reduction_type == 'right': retval[_triangleRightSide(degrees)] = coeffs for i in set(range( (degrees + 1)**2)) - set(_triangleRightSide(degrees)): l = np.sqrt(i).astype('int') m = abs((l) - (i - l**2)) retval[i] = (-1)**m * np.conj(retval[l**2 + l + m]) return retval if __name__ == '__main__': from matplotlib import pyplot as plt e = EnvironmentMap('envmap.exr', 'angular') e.resize((64, 64)) e.convertTo('latlong') se = SphericalHarmonic(e) err = [] from tqdm import tqdm for i in tqdm(range(32)): recons = se.reconstruct(max_l=i) err.append(np.sum((recons - e.data)**2)) plt.plot(err) plt.figure() plt.imshow(recons) plt.show()
elif reduction_type == 'right': retval[_triangleRightSide(degrees)] = coeffs for i in set(range((degrees + 1)**2)) - set(_triangleRightSide(degrees)): l = np.sqrt(i).astype('int') m = abs((l) - (i - l**2)) retval[i] = (-1)**m * np.conj(retval[l**2 + l + m]) return retval raise Exception('unknown reduction_type') if __name__ == '__main__': from matplotlib import pyplot as plt e = EnvironmentMap('envmap.exr', 'angular') e.resize((256, 256)) e.convertTo('latlong') # P, nodes = _getP(e, 15) # refP = _getRefP(np.cos(nodes), 15) # for i in range(P.shape[1] - 5, P.shape[1]): # plt.plot(np.linspace(-1, 1, P.shape[0]), P[:,i], label="{}".format(i)) # plt.plot(np.linspace(-1, 1, P.shape[0]), refP[:,i], label="ref{}".format(i)) # plt.legend(); # plt.show() # import pdb; pdb.set_trace() coeffs_fsht = FSHT(e.copy(), 25)