def _match_label_with_color(label, colors, bg_label, bg_color):
 if (bg_color is None):
  bg_color = (0, 0, 0)
 bg_color = _rgb_vector([bg_color])
 (unique_labels, mapped_labels) = np.unique(label, return_inverse=True)
 bg_label_rank_list = mapped_labels[(label.flat == bg_label)]
 if (len(bg_label_rank_list) > 0):
  bg_label_rank = bg_label_rank_list[0]
  mapped_labels[(mapped_labels < bg_label_rank)] += 1
  mapped_labels[(label.flat == bg_label)] = 0
 else:
  mapped_labels += 1
 color_cycle = itertools.cycle(colors)
 color_cycle = itertools.chain(bg_color, color_cycle)
 return (mapped_labels, color_cycle)

def _match_label_with_color ( label , colors , bg_label , bg_color ) : if ( bg_color is None ) : bg_color = ( 0 , 0 , 0 ) bg_color = _rgb_vector ( [ bg_color ] ) ( unique_labels , mapped_labels ) = np . unique ( label , return_inverse = True ) bg_label_rank_list = mapped_labels [ ( label . flat == bg_label ) ] if ( len ( bg_label_rank_list ) > 0 ) : bg_label_rank = bg_label_rank_list [ 0 ] mapped_labels [ ( mapped_labels < bg_label_rank ) ] += 1 mapped_labels [ ( label . flat == bg_label ) ] = 0 else : mapped_labels += 1 color_cycle = itertools . cycle ( colors ) color_cycle = itertools . chain ( bg_color , color_cycle ) return ( mapped_labels , color_cycle )
return unique_labels and color_cycle for label array and color list .