@@ -805,8 +805,7 @@ def _map_color_seg(
805805
806806 if seg_boundaries :
807807 seg_bound : ArrayLike = np .clip (seg_im - find_boundaries (seg )[:, :, None ], 0 , 1 )
808- seg_bound = np .dstack ((seg_bound , np .where (val_im > 0 , 1 , 0 ))) # add transparency here
809- return seg_bound
808+ return np .dstack ((seg_bound , np .where (val_im > 0 , 1 , 0 ))) # add transparency here
810809
811810 return np .dstack ((seg_im , np .where (val_im > 0 , 1 , 0 )))
812811
@@ -847,11 +846,11 @@ def _get_palette(
847846
848847 if isinstance (palette , str ):
849848 cmap = plt .get_cmap (palette )
850- palette = [to_hex (x ) for x in cmap (np .linspace (0 , 1 , len_cat ), alpha = alpha )]
851849 elif isinstance (palette , ListedColormap ):
852- palette = [ to_hex ( x ) for x in palette ( np . linspace ( 0 , 1 , len_cat ), alpha = alpha )]
850+ cmap = palette
853851 else :
854852 raise TypeError (f"Palette is { type (palette )} but should be string or `ListedColormap`." )
853+ palette = [to_hex (np .round (x , 5 )) for x in cmap (np .linspace (0 , 1 , len_cat ), alpha = alpha )]
855854
856855 return dict (zip (categories , palette ))
857856
0 commit comments