Exemplo n.º 1
0
def dkl2rgb2d(dkl, conversionMatrix=None):
    if conversionMatrix==None:
        conversionMatrix = numpy.asarray([ \
            #LUMIN    %L-M    %L+M-S  (note that dkl has to be in cartesian coords first!)
            [1.0000, 1.0000, -0.1462],#R
            [1.0000, -0.3900, 0.2094],#G
            [1.0000, 0.0180, -1.0000]])#B
        logging.warning('This monitor has not been color-calibrated. Using default DKL conversion matrix.')

    if len(dkl.shape)==3:

        origShape = dkl.shape
        elevation = dkl[:,:,0]
        azimuth = dkl[:,:,1]
        radius = dkl[:,:,2]
        dkl = numpy.asarray([elevation.reshape([-1]), azimuth.reshape([-1]), radius.reshape([-1])])
        LM, S, Lum = misc.sph2cart(elevation, azimuth, radius)

        rgb = misc.dklCart2rgb(LUM = Lum, LM = LM, S = S, conversionMatrix = conversionMatrix)
        rgb.reshape(origShape)
            if order==2:
                sigmaLumSecond += thisIntensity
        
    #    print sigma
        
        #Staircase chromatic blur for first image
        lmFirst = ndimage.gaussian_filter(lm, sigma=sigmaFirst, order=0, output=None, mode='reflect', cval=0.0)
        sFirst = ndimage.gaussian_filter(s, sigma=sigmaFirst, order=0, output=None, mode='reflect', cval=0.0)
        lumFirst = ndimage.gaussian_filter(lum, sigma=sigmaLumFirst)
        #Staircase chromatic blur for second image
        lmSecond = ndimage.gaussian_filter(lm, sigma=sigmaSecond, order=0, output=None, mode='reflect', cval=0.0)
        sSecond = ndimage.gaussian_filter(s, sigma=sigmaSecond, order=0, output=None, mode='reflect', cval=0.0)
        lumSecond = ndimage.gaussian_filter(lum, sigma=sigmaLumSecond)
        
        #change back to RGB
        rgbPictureFirst = misc.dklCart2rgb((lmFirst+sFirst)/2, lumFirst, lumFirst, conversionMatrix)
        rgbPictureSecond = misc.dklCart2rgb((lmSecond+sSecond)/2, lumSecond, lumSecond, conversionMatrix)

#        rgbPictureFirst = misc.dklCart2rgb(lumFirst, lmFirst, sFirst, conversionMatrix)
#        rgbPictureSecond = misc.dklCart2rgb(lumSecond, lmSecond, sSecond, conversionMatrix)
        
        #Divide all the values by 2 so that there is room for the increases caused by the Gaussian filter
        rgbPictureFirst=rgbPictureFirst/2
        rgbPictureSecond=rgbPictureSecond/2
               
    #    
        #Draw the picture
        imgFirst = visual.PatchStim(myWin, tex=rgbPictureFirst, units='deg', sf=(1/10.0), size=10.0)
        imgFirst.draw()
        myWin.flip()
        core.wait(info['displayT'])
Exemplo n.º 3
0
    s1 = copy.copy(dklGratingLum[:,:,2])*0
    
    lum2 = copy.copy(dklGratingLm[:,:,0])
    lm2 = copy.copy(dklGratingLm[:,:,1])*0
    s2 = copy.copy(dklGratingLm[:,:,2])*0
    

    
    lumlm = (lum2)/2.0              #peturb
    lmlm = (lum1)/2.0                #straight
    lmlm = np.rot90(lmlm)           #rotated perturb
    lumlm2 = np.rot90(lumlm)       #rotated straight 
    slm = np.empty((128,128))
    

    rgbPictureAllLm = misc.dklCart2rgb(lumlm, lmlm, slm)        #peturb full image
    rgbPictureStraight = misc.dklCart2rgb(lumlm, lumlm2, slm)   #straight full image

    imgAllLm = visual.PatchStim(myWin, tex = rgbPictureAllLm, size = 10.0, sf = 1/10.0)
    imgAllSt = visual.PatchStim(myWin, tex = rgbPictureStraight, size=10.0, sf=1/10.0)
    

    
    targettime= random.choice([0,1])        #set random order
    
    if targettime == 1:    
        img1 = imgAllLm
        img2 = imgAllSt
    else:
        img2 = imgAllLm  
        img1 = imgAllSt
Exemplo n.º 4
0
            #Create stimuli
        if thisStair.extraInfo['condition']=='LM':
            lum = colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)*0
            lm= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)
            s= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)*0
        if thisStair.extraInfo['condition']=='S':
            lum = colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)*0
            lm= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)*0
            s= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)
        if thisStair.extraInfo['condition']=='Lum':
            lum = colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)
            lm= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)*0
            s= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5)*0
        order = random.randint(1.0, 2.0)
       
        rgbEdge = misc.dklCart2rgb(lum, lm, s, conversionMatrix)
       
        #Draw the picture
        if order==1:
            if DEBUG==False:
                tick.play()
            img = visual.PatchStim(myWin, tex=rgbEdge, units='deg', size = 1.0, sf=(1/1.0), pos = (2.0, 0.0))
            drawPicture(info['baseContrast']+thisContrast, img)
                        #Draw mask
#            upperMask = visual.ShapeStim(myWin, units='deg', lineColor=(0,0,0), fillColor=(0,0,0), 
#                                    vertices=((-5,5), (5,5), (5,0.5), (-5,0.5)))
#            lowerMask = visual.ShapeStim(myWin, units='deg', lineColor=(0,0,0), fillColor=(0,0,0), 
#                                    vertices=((-5,-5), (5,-5), (5,-0.5), (-5,-0.5)))
#            upperMask.draw()
#            lowerMask.draw()
            myWin.flip()
Exemplo n.º 5
0
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()

Exemplo n.º 6
0
DEBUG=True

if DEBUG==True:
    myWin = visual.Window(size=(1024, 768), monitor = 'testMonitor', units = 'deg',
        fullscr=False, allowGUI=True, bitsMode=None)
    myMon = monitors.Monitor('testMonitor')
    conversionMatrix = None
    
info = {}
info['Blur'] = 0.01
edgeSize = 10.0
edgeSF = 1/10.0
edgePos = 0.5
   
lum = colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5, size=512)
lmlms= colorFunctions.makeEdgeGauss(width=info['Blur'],center=0.5, size=512)
slms= colorFunctions.makeEdgeGauss(width=info['Blur'],center=(0.5), size=512)
lm= colorFunctions.makeEdgeGauss(width=info['Blur'],center=(0.5), size=512)
s= colorFunctions.makeEdgeGauss(width=info['Blur'],center=(0.5), size=512)

Edge= misc.dklCart2rgb(LUM=lum, LM=lm, S=s, conversionMatrix = conversionMatrix)/2.0
if (np.max(Edge)>1.0) or (np.min(Edge)<-1.0):
    print 'contrast outside range'
    core.quit()
lum1 = visual.PatchStim(myWin, tex = Edge, size=edgeSize, units = 'deg', sf=edgeSF, pos=(edgePos, 0.0))
lum1.draw()

myWin.flip()
event.waitKeys()

Exemplo n.º 7
0
#img = visual.PatchStim(myWin, tex = grating, size=10.0, sf=1/10.0)
#img.draw()
#myWin.flip()

dklGratingLum = misc.rgb2dklCart(lumGrating)
dklGratingLm = misc.rgb2dklCart(lmGrating)

lum1 = copy.copy(dklGratingLum[:,:,0])
lm1 = copy.copy(dklGratingLum[:,:,1])*0
s1 = copy.copy(dklGratingLum[:,:,2])*0

lum2 = copy.copy(dklGratingLm[:,:,0])
lm2 = copy.copy(dklGratingLm[:,:,1])
s2 = copy.copy(dklGratingLm[:,:,2])

rgbPictureLum = misc.dklCart2rgb(lum1, lm1, s1)
rgbPictureLm = misc.dklCart2rgb(lm2, lum2, s2)

#Values for lum wavy
lumlum = (lm2+lum1)/2.0
lmlum = (lum2 + lm1)/2.0
lmlum = np.rot90(lmlum)
slum = s1+s2

#Valyes for lm wavy
lumlm = (lum2 + lm1)/2.0
lmlm = (lm2 + lum1)/2.0
lmlm = np.rot90(lmlm)
slm = s1+s2

#LumWavy