def make_yt_transfer(bounds=(0.0, 1.0), colormap="algae", bins=1000, scale=1.0, scale_func=None): """Defines a transfer function offset given a transfer function. """ mi, ma = bounds transfer = ColorTransferFunction((mi, ma), bins) if scale_func == None: transfer.map_to_colormap(mi, ma, colormap=colormap, scale=1.0) else: transfer.map_to_colormap(mi, ma, colormap=colormap, scale_func=scale_func) return transfer
def make_yt_transfer( bounds=(0.0, 1.0), colormap="algae", bins=1000, scale=1.0, scale_func=None): """Defines a transfer function offset given a transfer function. """ mi, ma = bounds transfer = ColorTransferFunction((mi, ma), bins) if scale_func == None: transfer.map_to_colormap(mi, ma, colormap=colormap, scale=1.0) else: transfer.map_to_colormap(mi, ma, colormap=colormap, scale_func=scale_func) return transfer
def main(): global window, ts, width, height (width, height) = (1024, 1024) glutInit(sys.argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH) glutInitWindowSize(width, height) glutInitWindowPosition(0, 0) window = glutCreateWindow("Stereo Volume Rendering") glutDisplayFunc(display) glutIdleFunc(idle) glutReshapeFunc(resize) glutMouseFunc(mouseButton) glutMotionFunc(mouseMotion) glutKeyboardFunc(keyPressed) init_gl(width, height) # create texture for blitting to screen create_texture(width, height) import pycuda.gl.autoinit import pycuda.gl cuda_gl = pycuda.gl create_PBO(width, height) # ----- Load and Set Volume Data ----- density_grid = np.load("/home/bogert/dd150_log_densities.npy") mi, ma = 21.5, 24.5 bins = 5000 tf = ColorTransferFunction((mi, ma), bins) tf.map_to_colormap(mi, ma, colormap="algae", scale_func=scale_func) ts = TheiaScene(volume=density_grid, raycaster=FrontToBackRaycaster(size=(width, height), tf=tf)) ts.get_raycaster().set_sample_size(0.01) ts.get_raycaster().set_max_samples(5000) ts.update() glutMainLoop()
def main(): global window, ts, width, height (width, height) = (1024, 1024) glutInit(sys.argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH ) glutInitWindowSize(width, height) glutInitWindowPosition(0, 0) window = glutCreateWindow("Stereo Volume Rendering") glutDisplayFunc(display) glutIdleFunc(idle) glutReshapeFunc(resize) glutMouseFunc( mouseButton ) glutMotionFunc( mouseMotion ) glutKeyboardFunc(keyPressed) init_gl(width, height) # create texture for blitting to screen create_texture(width, height) import pycuda.gl.autoinit import pycuda.gl cuda_gl = pycuda.gl create_PBO(width, height) # ----- Load and Set Volume Data ----- density_grid = np.load("/home/bogert/dd150_log_densities.npy") mi, ma= 21.5, 24.5 bins = 5000 tf = ColorTransferFunction( (mi, ma), bins) tf.map_to_colormap(mi, ma, colormap="algae", scale_func = scale_func) ts = TheiaScene(volume = density_grid, raycaster = FrontToBackRaycaster(size = (width, height), tf = tf)) ts.get_raycaster().set_sample_size(0.01) ts.get_raycaster().set_max_samples(5000) ts.update() glutMainLoop()
#load the uniform grid from a numpy array file bolshoi = "/home/bogert/log_densities_1024.npy" density_grid = np.load(bolshoi) #Set the TheiaScene to use the density_grid and #setup the raycaster for a resulting 1080p image ts = TheiaScene(volume=density_grid, raycaster=FrontToBackRaycaster(size=(1920, 1080))) #the min and max values in the data to color mi, ma = 0.0, 3.6 #setup colortransferfunction bins = 5000 tf = ColorTransferFunction((mi, ma), bins) tf.map_to_colormap(0.5, ma, colormap="spring", scale_func=scale_func) #pass the transfer function to the ray caster ts.source.raycaster.set_transfer(tf) #Initial configuration for start of video #set initial opacity and brightness values #then zoom into the center of the data 30% ts.source.raycaster.set_opacity(0.03) ts.source.raycaster.set_brightness(2.3) ts.camera.zoom(30.0) #path to ffmpeg executable FFMPEG_BIN = "/usr/local/bin/ffmpeg" pipe = sp.Popen(
#load the uniform grid from a numpy array file bolshoi = "/home/bogert/log_densities_1024.npy" density_grid = np.load(bolshoi) #Set the TheiaScene to use the density_grid and #setup the raycaster for a resulting 1080p image ts = TheiaScene(volume = density_grid, raycaster = FrontToBackRaycaster(size = (1920,1080) )) #the min and max values in the data to color mi, ma = 0.0, 3.6 #setup colortransferfunction bins = 5000 tf = ColorTransferFunction( (mi, ma), bins) tf.map_to_colormap(0.5, ma, colormap="spring", scale_func = scale_func) #pass the transfer function to the ray caster ts.source.raycaster.set_transfer(tf) #Initial configuration for start of video #set initial opacity and brightness values #then zoom into the center of the data 30% ts.source.raycaster.set_opacity(0.03) ts.source.raycaster.set_brightness(2.3) ts.camera.zoom(30.0) #path to ffmpeg executable FFMPEG_BIN = "/usr/local/bin/ffmpeg" pipe = sp.Popen([ FFMPEG_BIN,