Пример #1
0
            public void WhiteRgbToLab()
            {
				var knownColor = new Rgb { R = 255, G = 255, B = 255, };
				var expectedColor = new Lab { L = 100, A = 0.00526, B = -.0104, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #2
0
            public void DarkVioletCmykToLab()
            {
                var knownColor = new Cmyk { C = .29858, M = 1, Y = 0, K = .17255, };
                var expectedColor = new Lab { L = 39.579, A = 76.336, B = -70.378, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #3
0
            public void Initialize()
            {
                TestData = new Dictionary<KeyValuePair<ILab, ILab>, double>();
                var reader =
                    new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory +
                                               @"/TestData/CieDe2000TestData.dat");
                string line;

                while ((line = reader.ReadLine()) != null)
                {
                    if (string.IsNullOrEmpty(line)) continue;
                    if (line.StartsWith("//")) continue;

                    var parts = line.Split('\t');
                    var a = new Lab
                        {
                            L = Double.Parse(parts[0]),
                            A = Double.Parse(parts[1]),
                            B = Double.Parse(parts[2])
                        };
                    var b = new Lab
                        {
                            L = Double.Parse(parts[3]),
                            A = Double.Parse(parts[4]),
                            B = Double.Parse(parts[5])
                        };
                    var input = new KeyValuePair<ILab, ILab>(a, b);
                    var expected = Double.Parse(parts[6]);
                    TestData[input] = expected;
                }
            }
Пример #4
0
 public bool Equals(Lab other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.L == L && other.A == A && other.B == B);
 }
Пример #5
0
            public void ReturnsKnownValueForDissimilarColors()
            {
                // Todo, should be mocking!!
                var a = new Lab
                    {
                        L = 50,
                        A = 67,
                        B = 88
                    };

                var b = new Lab
                    {
                        L = 50,
                        A = 15,
                        B = 22
                    };

                ReturnsExpectedValueForKnownInput(84.0238, a, b);
            }
Пример #6
0
            public void ReturnsKnownValueForWhiteAndEggShell1()
            {
                // Todo, should be mocking!!
                var a = new Lab
                {
                    L = 100,
                    A = 0,
                    B = 0
                };

                var b = new Lab
                {
                    L = 89.9490,
                    A = 13.8320,
                    B = 6.8160
                };

                ReturnsExpectedValueForKnownInput(25.103175, 1, a, b);
            }
Пример #7
0
            public void ReturnsKnownValueForRedAndMaroon2()
            {
                // Todo, should be mocking!!
                var a = new Lab
                {
                    L = 24.8290,
                    A = 60.0930,
                    B = 38.1800
                };

                var b = new Lab
                {
                    L = 53.2300,
                    A = 80.1090,
                    B = 67.2200
                };

                ReturnsExpectedValueForKnownInput(24.143033, 2, a, b);
            }
Пример #8
0
            public void ReturnsKnownValueForSimilarColors()
            {
                // Todo, should be mocking!!
                var a = new Lab
                {
                    L = 88.17,
                    A = 67,
                    B = 88
                };

                var b = new Lab
                {
                    L = 87.16,
                    A = 65,
                    B = 66
                };

                ReturnsExpectedValueForKnownInput(22.1138, a, b);
            }
Пример #9
0
		public DeltaEMap Calculate(Lab target, Lab[,] palette)
		{
			var height = palette.GetLength(0);
			var width = palette.GetLength(1);

			BeginTrack(nameof(Calculate), "Calculating DeltaE");

			var results = new double[height, width];

			Parallel.For(0, height, i =>
			{
				for (var j = 0; j < width; j++)
					results[i, j] = palette[i, j].Compare(target, CieDe2000);
			});

			EndTrack(nameof(Calculate), "Calculated DeltaE map");

			return new DeltaEMap(results);
		}
Пример #10
0
            public void ReturnsKnownValueForGraphicArtsPinks()
            {
                // Todo, should be mocking!!
                var a = new Lab
                    {
                        L = 70.1,
                        A = 53,
                        B = -3.2
                    };

                // Todo, should be mocking!!
                var b = new Lab
                {
                    L = 67.4,
                    A = 47.7,
                    B = -5.34
                };

                ReturnsExpectedValueForKnownInput(3.408967, Cie94Comparison.Application.GraphicArts, a, b);
            }
Пример #11
0
        public Form1()
        {
            InitializeComponent();
            rangeValue = Convert.ToInt32(textBoxSensivity.Text);
            previousBitmaps = new List<BackStepItem>();
            pixelDatas = new List<PixelData>();
            pixelInfo = new List<PixelInfo>();
            labInfo = new List<LabInfo>();
            labDatas = new List<Lab>();

            var lLab = new Lab();
            lLab.L = 100;
            var aLab = new Lab();
            aLab.A = 127;
            var bLab = new Lab();
            bLab.B = 127;

            redWrap = new ZedGraphWrap(zedGraph, Color.Red, lLab);
            greenWrap = new ZedGraphWrap(zedGraph1, Color.Green, aLab);
            blueWrap = new ZedGraphWrap(zedGraph2, Color.Blue, bLab);
            pictureBoxPick.BackColor = Color.Black;
        }
Пример #12
0
        private unsafe Lab[,] ToLab()
        {
            var lab = new Lab[Height, Width];

            var x = 0;
            var y = 0;

            fixed (int* scan0 = &Data[0,0])
            {
                for (var i = 0; i < Data.Length; i++)
                {
                    var ptr = (byte*)scan0 + i * sizeof(int);
                    lab[y, x] = (new Rgb {R = ptr[2], G = ptr[1], B = ptr[0]}).To<Lab>();

                    if (++x == Width)
                    {
                        x = 0;
                        y++;
                    }
                }
            }

            return lab;
        }
Пример #13
0
            public void RedLabToCmyk()
            {
                var knownColor = new Lab { L = 53.233, A = 80.109, B = 67.220, };
                var expectedColor = new Cmyk { C = 0.0039, M = .99970, Y = 1, K = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #14
0
            public void MaroonLchToLab()
            {
                var knownColor = new Lch { L = 24.829, C = 60.093, H = 38.180, };
                var expectedColor = new Lab { L = 25.531, A = 48.055, B = 38.059, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #15
0
            public void BlackRgbToLab()
            {
                var knownColor = new Rgb { R = 0, G = 0, B = 0, };
                var expectedColor = new Lab { L = 0, A = 0, B = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #16
0
            public void RedLabToXyz()
            {
                var knownColor = new Lab { L = 53.233, A = 80.109, B = 67.220, };
                var expectedColor = new Xyz { X = 41.240, Y = 21.260, Z = 1.930, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #17
0
            public void RedLabToYxy()
            {
                var knownColor = new Lab { L = 53.233, A = 80.109, B = 67.220, };
                var expectedColor = new Yxy { Y1 = 21.260, X = 0.64007, Y2 = .32997, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #18
0
            public void RedLabToLch()
            {
                var knownColor = new Lab { L = 53.233, A = 80.109, B = 67.220, };
                var expectedColor = new Lch { L = 53.33, C = 104.575, H = 40, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #19
0
            public void RedLabToRgb()
            {
                var knownColor = new Lab { L = 53.233, A = 80.109, B = 67.220, };
                var expectedColor = new Rgb { R = 255, G = 0, B = 0, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #20
0
            public void GoldenrodRgbToLab()
            {
                var knownColor = new Rgb { R = 218, G = 165, B = 32, };
                var expectedColor = new Lab { L = 70.816, A = 8.525, B = 68.765, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #21
0
            public void RivergumXyzToLab()
            {
                var knownColor = new Xyz { X = 13.123, Y = 15.372, Z = 13.174, };
                var expectedColor = new Lab { L = 46.140, A = -9.421, B = 8.218, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #22
0
            public void AliceBlueHslToLab()
            {
                var knownColor = new Hsl { H = 208, S = 100, L = 97, };
                var expectedColor = new Lab { L = 97.179, A = -1.3688, B = -4.358, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #23
0
            public void SteelBlueCmyToLab()
            {
                var knownColor = new Cmy { C = .72549, M = .49020, Y = .29412, };
                var expectedColor = new Lab { L = 52.467, A = -4.070, B = -32.198, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
 public ZedGraphWrap(ZedGraphControl graphControl, Color color, Lab lab)
 {
     GraphControl = graphControl;
     Color = color;
     Lab = lab;
 }
Пример #25
0
            public void MaroonLchToLab()
            {
                var knownColor = new Lch { L = 24.829, C = 60.093, H = 38.180, };
                var expectedColor = new Lab { L = 24.829, A = 47.237, B = 37.146, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #26
0
            public void AquamarineHsvToLab()
            {
                var knownColor = new Hsv { H = 160, S = .5, V = 1, };
                var expectedColor = new Lab { L = 92.036, A = -45.521, B = 9.49689, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #27
0
            public void SilverLuvToLab()
            {
                var knownColor = new Luv { L = 77.704, U = .001, V = -.013, };
                var expectedColor = new Lab { L = 77.704, A = .0026, B = -.00696, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }
Пример #28
0
            public void RedLabToHsl()
            {
                var knownColor = new Lab { L = 53.233, A = 80.109, B = 67.220, };
                var expectedColor = new Hsl { H = 0, S = 100, L = 50, };

                ExpectedValuesForKnownColor(knownColor,expectedColor);
            }