I am using a Dictionary to store the frequency of colors in an image, where the key is the the color (as an int), and the value is the number of
Dictionary
Try using an array instead. I doubt it will run out of memory. 6 million int array elements is not a big deal.