def initTexture(self): data = np.load(self.texture_file) data = rescale_data_to_image(data) w, h = data.shape # generate a texture id, make it current self.texture = gl.glGenTextures(1) gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture) # texture mode and parameters controlling wrapping and scaling gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_REPEAT) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_REPEAT) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) # map the image data to the texture. note that if the input # type is GL_FLOAT, the values must be in the range [0..1] gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, w, h, 0, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, data)
__author__ = 'mavinm' __date__ = '3/21/14' if __name__ == "__main__": filenames = { "tmp/bc_data_gaussian_sigma=0.001.bin": "report/bc_gaussian-0.001.png", "tmp/bc_data_gaussian_sigma=0.002.bin": "report/bc_gaussian-0.002.png", "tmp/bc_data_gaussian_sigma=0.003.bin": "report/bc_gaussian-0.003.png", "tmp/bc_data_gaussian_sigma=0.004.bin": "report/bc_gaussian-0.004.png", "tmp/gc_data_gaussian_sigma=0.001.bin": "report/gc_gaussian-0.001.png", "tmp/gc_data_gaussian_sigma=0.002.bin": "report/gc_gaussian-0.002.png", "tmp/gc_data_gaussian_sigma=0.003.bin": "report/gc_gaussian-0.003.png", "tmp/gc_data_gaussian_sigma=0.004.bin": "report/gc_gaussian-0.004.png", "tmp/mea_lea_data_gaussian_sigma=0.001.bin": "report/mea_lea_gaussian-0.001.png", "tmp/mea_lea_data_gaussian_sigma=0.002.bin": "report/mea_lea_gaussian-0.002.png", "tmp/mea_lea_data_gaussian_sigma=0.003.bin": "report/mea_lea_gaussian-0.003.png", "tmp/mea_lea_data_gaussian_sigma=0.004.bin": "report/mea_lea_gaussian-0.004.png", } for fn, out in filenames.iteritems(): data = np.load(fn) sigma = fn.split("=")[1].rstrip(".bin") print sigma rescaled = rescale_data_to_image(data) im = Image.fromarray(rescaled) im.save(out)