Posts

Showing posts from July, 2013

Identifying the most dominant color in an image

Hi, I developed an algorithm that identifies the most dominant color in an image. The input is a URL to the target image and the output is the dominant color. The algorithm reads all the pixels of the bitmap and maps them into a dictionary. Then, it builds a graph of similar colors by a pre-defined threshold. While building the graph, the algorithm maintains the most dominant color by the node that has the largest amount of pixels combined with its' adjacent nodes. public class ColorsGraph { private const int _similarityThreshhold = 30; private readonly Dictionary<Color, int> _colorsMapping; private Dictionary<ColorNode, List<ColorNode>> _colorsGraph; private KeyValuePair<ColorNode, List<ColorNode>> _mostDominantColor; public ColorsGraph(string imageUrl) { _colorsMapping = new Dictionary<Color, int>(); var request = WebRequest.Create(imageUrl); using (var response = request.GetResponse