private static int GetSaturation(Color rgb)
{
// Find the smallest of all three parameters.
float low = Math.Min(rgb.R, Math.Min(rgb.G, rgb.B));
// Find the highest of all three parameters.
float high = Math.Max(rgb.R, Math.Max(rgb.G, rgb.B));
// The difference between the last two variables
// divided by the highest is the saturation.
return (int)Math.Round(100 * ((high - low) / high));
}