Skip to content

Commit

Permalink
Add ubyte option to random_colors_hsv
Browse files Browse the repository at this point in the history
  • Loading branch information
ericup committed Dec 6, 2024
1 parent e49b099 commit 532587f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions celldetection/visualization/cmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
__all__ = ['label_cmap', 'random_colors_hsv']


def random_colors_hsv(num, hue_range=(0, 180), saturation_range=(60, 133), value_range=(180, 256)):
def random_colors_hsv(num, hue_range=(0, 180), saturation_range=(60, 133), value_range=(180, 256), ubyte=False):
colors, = cv2.cvtColor(np.stack((
np.random.randint(*hue_range, num),
np.random.randint(*saturation_range, num),
np.random.randint(*value_range, num),
), 1).astype('uint8')[None], cv2.COLOR_HSV2RGB) / 255
), 1).astype('uint8')[None], cv2.COLOR_HSV2RGB)
if not ubyte:
colors = colors / 255
return colors


Expand Down

0 comments on commit 532587f

Please sign in to comment.