#NEWLINE# def hsv_to_rgb( hsv ) : #NEWLINE# #INDENT# '\n    Vectorized HSV to RGB conversion, adapted from:\n    http://stackoverflow.com/questions/24852345/hsv-to-rgb-color-conversion\n    ' #NEWLINE# ( h , s , v ) = ( hsv [ ( ... , i ) ] for i in range ( 3 ) ) #NEWLINE# shape = h . shape #NEWLINE# i = np . int_ ( ( h * 6.0 ) ) #NEWLINE# f = ( ( h * 6.0 ) - i ) #NEWLINE# q = f #NEWLINE# t = ( 1.0 - f ) #NEWLINE# i = np . ravel ( i ) #NEWLINE# f = np . ravel ( f ) #NEWLINE# i %= 6 #NEWLINE# t = np . ravel ( t ) #NEWLINE# q = np . ravel ( q ) #NEWLINE# s = np . ravel ( s ) #NEWLINE# v = np . ravel ( v ) #NEWLINE# clist = ( ( 1 - ( s * np . vstack ( [ np . zeros_like ( f ) , np . ones_like ( f ) , q , t ] ) ) ) * v ) #NEWLINE# order = np . array ( [ [ 0 , 3 , 1 ] , [ 2 , 0 , 1 ] , [ 1 , 0 , 3 ] , [ 1 , 2 , 0 ] , [ 3 , 1 , 0 ] , [ 0 , 1 , 2 ] ] ) #NEWLINE# rgb = clist [ ( order [ i ] , np . arange ( np . prod ( shape ) ) [ : , None ] ) ] #NEWLINE# return rgb . reshape ( ( shape + ( 3 , ) ) )