Answer the question
In order to leave comments, you need to log in
How can you identify the 2-3 most used colors in an image?
There is an image (20x20 or so, small.) You need to convert it to ASCII graphics for the terminal. You can then use colors. I think first to simplify it to these very 2-3 colors, and then rewrite it into text. But I don’t know how to find the colors to which to simplify.
I would be grateful if you write a few pieces of code with comments.
Answer the question
In order to leave comments, you need to log in
The first thing that comes to mind is the K-means clustering algorithm . As far as I know, it is often used to build palettes when converting an image to index colors. That is, even if the image does not have 2 clear dominant colors, but there are similar shades (small gradients, shading or lightening), then it will find their average values.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question