Get Color Saturation Distance - CSharp System.Drawing

CSharp examples for System.Drawing:Color HSV

Description

Get Color Saturation Distance

Demo Code


using System.Windows.Media;

public class Main{
        public static double GetSaturationDistance(Color a, Color b)
      {/*from w w  w .  ja  v  a 2s.co m*/
         double dist = System.Math.Abs(GetSaturation(a.R, a.G, a.B) - GetSaturation(b.R, b.G, b.B));

         return System.Math.Min(dist, 100 - dist);
      }
        public static double GetSaturationDistance(byte aR, byte aG, byte aB, Color b)
      {
         double dist = System.Math.Abs(GetSaturation(aR, aG, aB) - GetSaturation(b.R, b.G, b.B));

         return System.Math.Min(dist, 100 - dist);
      }
        public static double GetSaturationDistance(byte aR, byte aG, byte aB, byte bR, byte bG, byte bB)
      {
         double dist = System.Math.Abs(GetSaturation(aR, aG, aB) - GetSaturation(bR, bG, bB));

         return System.Math.Min(dist, 100 - dist);
      }
}

Related Tutorials