Beispiel #1
0
def test_HSV_RGB():
    HSV = numpy.array([
        [0, 1, 1],
        [0, 1, 0.5],  #reducing Value reduces intensity of primary gun
        [0, 0.5, 0.5],  #reducing Saturation increases intensity of other guns
        [30, 1, 1],
        [60, 1, 1],
        [90, 1, 1],
        [120, 1, 1],
        [150, 1, 1],
        [180, 1, 1],
        [210, 1, 1],
        [240, 1, 1],
        [270, 1, 1],
        [300, 1, 1],
        [330, 1, 1],
        [360, 1, 1]
    ])
    expectedRGB = numpy.array([[1., -1., -1.], [0., -1., -1.],
                               [0., -0.5, -0.5], [1., 0., -1.], [1., 1., -1.],
                               [0., 1., -1.], [-1., 1., -1.], [-1., 1., 0.],
                               [-1., 1., 1.], [-1., 0., 1.], [-1., -1., 1.],
                               [0., -1., 1.], [1., -1., 1.], [1., -1., 0.],
                               [1., -1., -1.]])
    RGB = hsv2rgb(HSV)
    assert numpy.allclose(RGB, expectedRGB, 0.0001)
Beispiel #2
0
def test_HSV_RGB():
    HSV=numpy.array([
       [  0,   1,   1],
       [  0,   1, 0.5],#reducing Value reduces intensity of primary gun
       [  0,   0.5, 0.5],#reducing Saturation increases intensity of other guns
       [ 30,   1,   1],
       [ 60,   1,   1],
       [ 90,   1,   1],
       [120,   1,   1],
       [150,   1,   1],
       [180,   1,   1],
       [210,   1,   1],
       [240,   1,   1],
       [270,   1,   1],
       [300,   1,   1],
       [330,   1,   1],
       [360,   1,   1]])
    expectedRGB=numpy.array([
       [ 1. ,  -1. ,  -1. ],
       [ 0.,  -1. ,  -1. ],
       [ 0., -0.5,  -0.5],
       [ 1. ,  0.,  -1. ],
       [ 1. ,  1. ,  -1. ],
       [ 0.,  1. ,  -1. ],
       [ -1. ,  1. ,  -1. ],
       [ -1. ,  1. ,  0.],
       [ -1. ,  1. ,  1. ],
       [ -1. ,  0.,  1. ],
       [ -1. ,  -1. ,  1. ],
       [ 0.,  -1. ,  1. ],
       [ 1. ,  -1. ,  1. ],
       [ 1. ,  -1. ,  0.],
       [ 1. ,  -1. ,  -1. ]])
    RGB = hsv2rgb(HSV)
    assert numpy.allclose(RGB,expectedRGB,0.0001)
Beispiel #3
0
 def hsv(self, color):
     # Validate
     color, space = self.validate(color=color, space='hsv')
     if space != 'hsv':
         setattr(self, space)
         return
     # Apply via rgba255
     self.rgb = ct.hsv2rgb(color)
     # Clear outdated values from cache
     self._cache = {'hsv': color}
Beispiel #4
0
                                sizes=WHEELWIDTH,
                                elementMask='circle',
                                elementTex='none',
                                texRes=400,
                                phases=1)
'''
choose the color space
can either use
(1) colors differing in hue or
(2) draw a circle in lab color space

comment out line you don't want to use
'''

colors = hsv2rgb(
    [[i, 1, .8] for i in range(360)]
)  # creates 360 color values differing in hue and converts them to rgb [-1,1] format

# colors = LAB2RGB(L = 60, a = 20, b = 20, radius = 60) # uses function from extras.py to convert lab to rgb
# note that these colors won't be rendered exactly as intended if the monitor isn't calibrated properly
# see https://www.ncbi.nlm.nih.gov/pubmed/24715329

stim = []  # this loop creates 8 circle objects
for s in range(8):
    stim.append(visual.Circle(win, radius=.5))
# or
#stim = [visual.Circle(win, radius=.5) for s in range(8)]


def circle_locs(radius, angles=None):
    # function for defining locations on a circle with a certain radius at specific angles