示例#1
0
        public static Double CompareCieLAB(Image img1, Image img2, IlluminantItem _userIlluminant)
        {
            CieLAB CieLABItem1 = TranFormImageToCieLAB(img1, _userIlluminant),
                   CieLABItem2 = TranFormImageToCieLAB(img2, _userIlluminant);

            return(CompareCieLAB(CieLABItem1, CieLABItem2));
        }
示例#2
0
        private static CieLAB TranFormImageToCieLAB(Image image, IlluminantItem _userIlluminant)
        {
            var averageRGB = new AverageRGB(image);
            var XYZ        = new XYZ(averageRGB);
            var cieLAB     = new CieLAB(XYZ, _userIlluminant);

            return(cieLAB);
        }
示例#3
0
        public CieLAB(XYZ xYZ, IlluminantItem illuminant)
        {
            var x = illuminant.RefX - xYZ.X;
            var y = illuminant.RefY - xYZ.Y;
            var z = illuminant.RefZ - xYZ.Z;

            var xyz = new Dictionary <String, Double>()
            {
                { "X", x }, { "Y", y }, { "Z", z }
            };

            foreach (var pos in xyz)
            {
                var posValue = (pos.Value > 0.008856) ? Math.Pow(pos.Value, (1 / 3)) : (7.787 * pos.Value) + (16 / 116);
            }

            _cieL = (116 * xyz["Y"]) - 16;
            _cieA = 500 * (xyz["X"] - xyz["Y"]);
            _cieB = 200 * (xyz["Y"] - xyz["Z"]);
        }
示例#4
0
        private static void IntialiseIlluminantItem()
        {
            String observer        = String.Empty,
                   illuminantInput = String.Empty;

            while (String.IsNullOrWhiteSpace(observer) || !(observer.Equals("0") || observer.Equals("1")))
            {
                Console.WriteLine($"\nPlease select of Observer by typing 0 - (2° (CIE 1931)) or 1 (10° (CIE 1964))");
                observer = Console.ReadLine();
            }

            var count = 1;

            foreach (var illuminant in IlluminantReference.IlluminantCollection)
            {
                var xVal = observer.Equals("0") ? illuminant.x2 : illuminant.x10;
                var yVal = observer.Equals("0") ? illuminant.y2 : illuminant.y10;
                var zVal = observer.Equals("0") ? illuminant.z2 : illuminant.z10;

                Console.WriteLine($"number  :{count} - {illuminant.illuminant} - X :{xVal} - Y :{xVal} - Z :{xVal}");

                count++;
            }

            while (String.IsNullOrWhiteSpace(illuminantInput))
            {
                Console.WriteLine($"Please select of option by typing the number of the item");
                illuminantInput = Console.ReadLine();
                var isValid = false;
                for (var i = 1; i < count; i++)
                {
                    if (illuminantInput.Equals(i.ToString()))
                    {
                        isValid = true;
                    }
                }
                illuminantInput = isValid ? illuminantInput : String.Empty;
            }

            _userIlluminant = new IlluminantItem(IlluminantReference.IlluminantCollection[Convert.ToInt32(illuminantInput)], observer);
        }