Hi Nicolas,
hopefully this will run for you:
import glumpy
import numpy as np
import OpenGL
import OpenGL.GL as gl
import OpenGL.GLU as glu
import OpenGL.GLUT as glut
import loadtiff as loadtiff
#import pickle
#f = open('refimg.pickle','r')
#refimg = pickle.load(f)
#f.close()
#f = open('img.pickle','r')
#img = pickle.load(f)
#f.close()
refimg = np.random.uniform(0., 1., (512, 512)).astype(np.float32)
img = np.random.uniform(0,1,(200,100)).astype(np.float32)
#refimg = loadtiff.loadtiff('/media/SPINDRIVE/local_data/stimtests/
120118/12011802/zdepth.tif')
#imgs = loadtiff.loadtiffsequence('/media/SPINDRIVE/local_data/
stimtests/120118/12011802/bar_6.tif')
#imgs = np.asarray(imgs,np.float32)
#img = imgs[0:50,:,:].mean(0)/4096.
#refimg = refimg/refimg.max()
#img = img/img.max()
#import pickle
#f = open('refimg.pickle','w')
#pickle.dump(refimg,f)
#f.close()
#f = open('img.pickle','w')
#pickle.dump(img,f)
#f.close()
A = np.random.uniform(0,1, (512,512,2)).astype(np.float32)
A[:,:,1] = np.ones_like(refimg).astype(np.float32)
A[:,:,0] = refimg
B = np.ones((img.shape[0],img.shape[1],4)).astype(np.float32)
B *= (0,0,0,.7)
#B[:,:,2] = img
#B[:,:,1] = img
B[:,:,0] = img
fig = glumpy.figure( (512,512) )
A_img = glumpy.Image(A)
A_img.x,A_img.y = 0,0
#A_img.theta = 0
B_img = glumpy.Image(B)
B_img.x,B_img.y = 0,0
#B_img.theta = 0
class simple(object):
def __init__(self):
self.tx, self.ty = 0,0;
self.tt = 0.
# @fig.event
def on_init(self):
print 'Inititalization'
gl.glEnable( gl.GL_BLEND )
gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA )
gl.glEnable(gl.GL_LINE_SMOOTH);
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_DONT_CARE);
# @fig.event
def on_draw(self):
tx = self.tx; ty = self.ty; tt =
self.tt
fig.clear()
gl.glLoadIdentity()
A_img.update()
A_img.draw(x=A_img.x, y=A_img.y, z=0.0, width=fig.width,
height=fig.height)
gl.glLoadIdentity()
gl.glPushMatrix()
gl.glTranslate(B_img.x+B_img.width/2.0, B_img.y+B_img.height/2.0,0)
gl.glRotate(B_img.theta,0,0,1)
B_img.draw(x=-B_img.width/2., y=-B_img.height/2.,
z=1.0 ,width=img.shape[1], height=img.shape[0])
gl.glPopMatrix()
def on_mouse_motion(self, x, y, dx, dy):
pass
def on_mouse_drag(self, x, y, dx, dy, button):
print 'Mouse drag (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f, button=
%d)' % (x,y,dx,dy,button)
if (button == 2):
B_img.x = B_img.x + dx
B_img.y = B_img.y + dy
if (button == 8):
B_img.theta = B_img.theta + dy/10.
fig.redraw()
def on_key_press(self, symbol, modifiers):
print 'Key pressed (symbol=%s, modifiers=%s)'% (symbol,modifiers)
def on_key_release(self, symbol, modifiers):
print 'Key released (symbol=%s, modifiers=%s)'% (symbol,modifiers)
if(symbol == 102):
print 'f'
def on_mouse_scroll(self, x, y, scroll_x, scroll_y):
pass
s = simple()
fig.push(s)
fig.show()