#test colorspaces from psychopy import misc import scipy testDKL1 = scipy.asarray([45,90,1.0]) print testDKL1 print misc.dkl2rgb(testDKL1) #print misc.dkl2rgb(testDKL2) #print misc.dkl2rgb(testDKL3) #print misc.dkl2rgb(testDKL4)
def dkl2rgb(dkl): """ takes a DKL color as input and returns the corresponding RGB color """ from numpy import array from psychopy.misc import dkl2rgb return dkl2rgb(array(dkl))
#test colorspaces from psychopy import misc import scipy testDKL1 = scipy.asarray([45, 90, 1.0]) print testDKL1 print misc.dkl2rgb(testDKL1) #print misc.dkl2rgb(testDKL2) #print misc.dkl2rgb(testDKL3) #print misc.dkl2rgb(testDKL4)
edgeSF = 1/10.0 edgePos = 0.5 lum = colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5, size=512) lm= colorFunctions.makeEdgeGauss(width=info['Blur'],center=(0.5), size=512)*0.0 s= colorFunctions.makeEdgeGauss(width=info['Blur'],center=(0.5), size=512) sphEdge = misc.cart2sph(z = lum, y = s, x = lm) print len(sphEdge.shape) #print sphEdge[:,:,0][0] temp = copy.copy(sphEdge[:,:,1])+1 temp = (temp/numpy.abs(temp))*-15.0 sphEdge[:,:,0] += temp #print sphEdge[:,:,0][0] cartEdge = misc.dklCart2rgb(lum, lm, s)/2.0 Edge= misc.dkl2rgb(sphEdge, conversionMatrix = None)/2.0 lum1 = visual.PatchStim(myWin, tex = Edge, size=edgeSize, units = 'deg', sf=edgeSF, pos=(0.0, 0.0)) lum1.draw() myWin.flip() event.waitKeys()
def __init__(self, win, tex ="sin", mask ="none", units ="", pos =(0.0,0.0), size =(0.5,0.5), sf =(1.0,1.0), ori =0.0, phase =(0.0,0.0), texRes =128, rgb =[1.0,1.0,1.0], dkl=None, lms=None, contrast=1.0, opacity=1.0, depth=0, rgbPedestal = [0.0,0.0,0.0], interpolate=False): self.win = win if len(units): self.units = units else: self.units = win.units self.ori = float(ori) self.texRes = texRes #must be power of 2 self.contrast = float(contrast) self.opacity = opacity #for rgb allow user to give a single val and apply to all channels if type(rgb)==float or type(rgb)==int: #user may give a luminance val self.rgb=scipy.array((rgb,rgb,rgb), scipy.Float) else: self.rgb = scipy.asarray(rgb, scipy.Float) if type(rgbPedestal)==float or type(rgbPedestal)==int: #user may give a luminance val self.rgbPedestal=scipy.array((rgbPedestal,rgbPedestal,rgbPedestal), scipy.Float) else: self.rgbPedestal = scipy.asarray(rgbPedestal, scipy.Float) if dkl: self.dkl = dkl self.rgb = misc.dkl2rgb(dkl, win.dkl_rgb) elif lms: self.lms = lms warn('LMS-to-RGB conversion is not properly tested yet - it should NOT be used for proper research!') self.rgb = misc.lms2rgb(lms, win.lms_rgb) #phase (ranging 0:1) if type(phase) in [tuple,list]: self.phase = scipy.array(phase) else: self.phase = scipy.array((phase,0),scipy.Float) #sf if type(sf) in [tuple,list]: self.sf = scipy.array(sf,scipy.Float) else: self.sf = scipy.array((sf,sf),scipy.Float) self.pos = scipy.array(pos) if depth==0: self.depth = win._defDepth win._defDepth -= 0.0001# -ve depth means closer to viewer else: self.depth=depth #size if type(size) in [tuple,list]: self.size = scipy.array(size,scipy.Float) else: self.size = scipy.array((size,size),scipy.Float)#make a square if only given one dimension #initialise textures for stimulus (self.texID, self.maskID) = GL.glGenTextures(2) self._setTex(tex) self._setMask(mask) #generate a displaylist ID self._listID = GL.glGenLists(1) self._updateList()#ie refresh display list