def mapSamplesOntoSphere(self, sampler, numSamples): if not self.data: self.emptySphere() if not self.integral: self.precomputeIntegral(sampler.npData) samples = sampler.cdfSamples(numSamples) sampleValues = sampler.sampleValues() for i, v in np.ndenumerate(self.data[self.data!=0]): theta, phi = thetaPhiFromLatlong((i[0], i[1]), npData) x,y,z = cartesianCoord( (theta, phi) ) rgbValue = self.integral * monteCarloSum(sampleValues, (i))
def mapSamplesOntoSphere(self, sampler, numSamples): if not self.data: self.emptySphere() if not self.integral: self.precomputeIntegral(sampler.npData) samples = sampler.cdfSamples(numSamples) sampleValues = sampler.sampleValues() for i, v in np.ndenumerate(self.data[self.data!=0]): theta, phi = thetaPhiFromLatlong((i[0], i[1]), npData) x,y,z = cartesianCoord( (theta, phi) ) rgbValue = self.integral * monteCarloSum(sampleValues, (i)) def saveSphereImage(self, filepath, asFloatingPoint): pass if __name__ == '__main__': workingdir = '/Users/paul/github/hdr' grace_filepath = '/Users/paul/Dropbox/Imperial/advanced-graphics/GraceCathedra/grace_latlong.pfm' sampler = FPSampler(grace_filepath) for i in [64, 256, 1024]: s = SampledSphere(511) s.emptySphere() s.precomputeIntegral() mcSamples = sampler.cdfSamples(i) values = sampler.imageValues(mcSamples) s.mapSamples(samples) s.saveSphereImage(workingdir+'sampledSphere_' + str(i) + '.pfm', True) s.saveSphereImage(workingdir+'sampledSphere_' + str(i) + '.pfm', False)