#NEWLINE# def __init__( self , image ) : #NEWLINE# #INDENT# if ( image . ndim not in [ 2 , 3 ] ) : #NEWLINE# #INDENT# raise ValueError ( ( 'ImageColorGenerator needs an image with ndim 2 or 3, got %d' % image . ndim ) ) #NEWLINE# #UNINDENT# if ( ( image . ndim == 3 ) and ( image . shape [ 2 ] not in [ 3 , 4 ] ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'A color image needs to have 3 or 4 channels, got %d' % image . shape [ 2 ] ) ) #NEWLINE# #UNINDENT# self . image = image