Generate random colors (RGB)

后端 未结 8 2068
-上瘾入骨i
-上瘾入骨i 2020-12-25 12:51

I just picked up image processing in python this past week at the suggestion of a friend to generate patterns of random colors. I found this piece of script online that gene

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-25 13:17

    A neat way to generate RGB triplets within the 256 (aka 8-byte) range is

    color = list(np.random.choice(range(256), size=3))

    color is now a list of size 3 with values in the range 0-255. You can save it in a list to record if the color has been generated before or no.

提交回复
热议问题