code_junkie

Algorithm for counting the number of unique colors in an image

Nov 11th, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.17 KB | None | 0 0
  1. var cnt = new HashSet<System.Drawing.Color>();
  2.  
  3. foreach (Color pixel in image)
  4. cnt.Add(pixel);
  5.  
  6. Console.WriteLine("The image has {0} distinct colours.", cnt.Count);
Add Comment
Please, Sign In to add comment