Colour distance metric - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Colour distance metric

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Drawing;
using System.Collections.Generic;
using System;//from   ww w . j  a  v  a 2 s.co  m

public class Main{
        /// <summary>
        /// Colour distance metric
        /// </summary>
        /// <param name="c1"></param>
        /// <param name="c2"></param>
        /// <returns></returns>
        public static double ColorDifference(Color c1, Color c2)
        {
            return Math.Sqrt(Math.Pow(c1.R - c2.R, 2) + Math.Pow(c1.G - c2.G, 2) + Math.Pow(c1.B - c2.B, 2));
        }
}

Related Tutorials