def flatAzim(res, cone, ori=0.0, cycles=1.0, phase=0.0, elevation = 0.0):
    """Creates a grating defined either by S or LM in DKL space. The elevation
    can be changed whilst keeping the azimuth flat - in effect changing the position
    of the azimuth
    
    Warning: May generate values >1 or <-1
    
    :Parameters:
        res: integer
            the size of the resulting matrix on both dimensions (e.g 256)
        cone: 'LM' or 'S'
            which axis in DKL space the grating should be created in
        ori: float or int (default=0.0)
            the orientation of the grating in degrees
        cycles:float or int (default=1.0)
            the number of grating cycles within the array
        phase: float or int (default=0.0)
            the phase of the grating in degrees (NB this differs to most
            PsychoPy phase arguments which use units of fraction of a cycle)
        elevation: float or int (default=0.0)
            the angle that the azimuth will be changed to

    :Returns:
        a square numpy array of size resXres
        """

    gabor = filters.makeGrating(res, ori=ori, cycles = cycles, phase=phase)

    colorGabor = np.zeros((len(gabor), len(gabor), 3))
    colorGabor[:,:,0] = copy.copy(gabor)
    colorGabor[:,:,1] = copy.copy(gabor)
    colorGabor[:,:,2] = copy.copy(gabor)

    dklGabor = misc.rgb2dklCart(colorGabor)
    if cone=='LM':
        dklGabor = misc.cart2sph(dklGabor[:,:,0]*0.0, dklGabor[:,:,0]*0.0, dklGabor[:,:,0])
    if cone=='S':
        dklGabor = misc.cart2sph(dklGabor[:,:,0]*0.0, dklGabor[:,:,0], dklGabor[:,:,0]*0.0)
    if cone=='Lum':
        dklGabor = misc.cart2sph(dklGabor[:,:,0], dklGabor[:,:,0]*0.0, dklGabor[:,:,0]*0.0)

    temp = copy.copy(dklGabor[:,:,1])+1
    temp = (temp/np.abs(temp))*+elevation
    dklGabor[:,:,0] += temp

    rgbGabor = misc. dkl2rgb(dklGabor)
    return rgbGabor
Esempio n. 2
0
        #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
    
info = {}
info['Blur'] = 0.1
edgeSize = 10.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