Get Color Hue Distance - CSharp System.Drawing

CSharp examples for System.Drawing:Color HSV

Description

Get Color Hue Distance

Demo Code


using System.Windows.Media;

public class Main{
        public static double GetHueDistance(Color a, Color b)
      {/*from   w ww  . j a va 2s . com*/
         double dist = System.Math.Abs(GetHue(a.R, a.G, a.B) - GetHue(b.R, b.G, b.B));

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

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

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

Related Tutorials