numpy: unique list of colors in the image

前端 未结 5 1169
眼角桃花
眼角桃花 2020-12-16 15:54

I have an image img:

>>> img.shape
(200, 200, 3)

On pixel (100, 100) I have a nice color:

>>>         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 16:26

    If for any reason you will need to count the number of times each unique color appears, you can use this:

    from collections import Counter
    Counter([tuple(colors) for i in img for colors in i])
    

提交回复
热议问题