Exemplo n.º 1
0
        ///
        /// The smaller the number returned by this, the closer the colors are
        ///
        ///
        ///
        public int CompareTo(ColorFormulas oComparisionColor)
        {
            // Based upon the Delta-E (1976) formula at easyrgb.com (http://www.easyrgb.com/index.php?X=DELT&H=03#text3)
            double DeltaE = Math.Sqrt(Math.Pow((CieL - oComparisionColor.CieL), 2) + Math.Pow((CieA - oComparisionColor.CieA), 2) + Math.Pow((CieB - oComparisionColor.CieB), 2));

            return(Convert.ToInt16(Math.Round(DeltaE)));
        }
Exemplo n.º 2
0
        public static int ColorDiff(Color col1, Color col2)
        {
            Color temp = Color.Empty;

            if (col2.R < col1.R)
            {
                temp = col2;
            }
            else if (col2.R == col1.R && col2.G < col1.G)
            {
                temp = col2;
            }
            else if (col2.R == col1.R && col2.G == col1.G && col2.B < col1.B)
            {
                temp = col2;
            }

            if (temp != Color.Empty)
            {
                col2 = col1;
                col1 = temp;
            }

            ColorFormulas oColor1 = new ColorFormulas(col1.R, col1.G, col2.B);
            ColorFormulas oColor2 = new ColorFormulas(col2.R, col2.G, col2.B);

            return(oColor1.CompareTo(oColor2));
        }