A
A
Albatz2014-10-27 20:44:12
C++ / C#
Albatz, 2014-10-27 20:44:12

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

2 answer(s)
S
SHVV, 2014-10-28
@Albatz

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.

D
Don Kaban, 2014-11-01
@donkaban

Good post about clustering - habrahabr.ru/post/113393

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question