How to find the Dominant color in image?

后端 未结 9 580
花落未央
花落未央 2020-12-07 13:34

i want to find the dominant color in image, how can i do it ?

it would be great if i can get this in HEX code (exm: #eeeeee)

9条回答
  •  暖寄归人
    2020-12-07 13:54

    Sounds like a delightful code to write! I made a function awhile back that goes through every pixel and adds a shade to each one. What you could do is:

    For Each Pixel, find the highest color (r,g,or b) and do the math ($colorG++ or something)

    at the end, find out what one is the largest, and there would be your highest rgb shade.

    I wonder what color would come out if you used the resulting rgb value...

提交回复
热议问题