If you look at the actual pixel values, I would use a sorted dictionary:
SortedDictionary<Color,int>
and skip all the pixels. If you donβt know how to navigate pixels, check out Bitmap.LockBits . GetPixel will be too slow for your purposes.
Edit:
I am not 100% sure about sorting. I agree with CodeInChaos - a direct dictionary will probably be faster anyway. You will need to do one loop through the dictionary to get the most common meaning.
source share