コード例 #1
0
ファイル: Window1.xaml.cs プロジェクト: mattlant/RGBDiffLib
        private void btnUpdateRGB_Click(object sender, RoutedEventArgs e)
        {
            SetOutOfGamut(false);
            double r = double.Parse(txtR.Text);
            double g = double.Parse(txtG.Text);
            double b = double.Parse(txtB.Text);

            RGBColour rgb = RGBColour.FromRGB(r, g, b);

            XYZColour xyzcColour = ColourUtil.RGBtoXYZ(rgb);

            xyYColour xyYCol = xyYColour.FromXYZ(xyzcColour);

            txtXYZ_X.Text = xyzcColour.X.ToString();
            txtXYZ_Y.Text = xyzcColour.Y.ToString();
            txtXYZ_Z.Text = xyzcColour.Z.ToString();

            txtxyY_x.Text = xyYCol.x.ToString();
            txtxyY_y.Text = xyYCol.y.ToString();
            txtxyY_Y.Text = xyYCol.Y.ToString();

            Color newColourForRectangle = Color.FromRgb((byte)r, (byte)g, (byte)b);

            SolidColorBrush brush = new SolidColorBrush(newColourForRectangle);

            rectColour.Fill = brush;
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: mattlant/RGBDiffLib
        private void btnUpdatexyY_Click(object sender, RoutedEventArgs e)
        {
            SetOutOfGamut(false);
            double x = double.Parse(txtxyY_x.Text);
            double y = double.Parse(txtxyY_y.Text);
            double Y = double.Parse(txtxyY_Y.Text);

            xyYColour xyYCol = xyYColour.FromxyY(x, y, Y);

            XYZColour xyzColour = xyYCol.ToXYZColour();

            RGBColour rgbColour = ColourUtil.XYZTosRGB(xyzColour);

            txtR.Text = rgbColour.R.ToString();
            txtG.Text = rgbColour.G.ToString();
            txtB.Text = rgbColour.B.ToString();

            txtXYZ_X.Text = xyzColour.X.ToString();
            txtXYZ_Y.Text = xyzColour.Y.ToString();
            txtXYZ_Z.Text = xyzColour.Z.ToString();

            Color newColourForRectangle = Color.FromRgb((byte)rgbColour.R, (byte)rgbColour.G, (byte)rgbColour.B);

            SolidColorBrush brush = new SolidColorBrush(newColourForRectangle);

            rectColour.Fill = brush;

            SetOutOfGamut(rgbColour.OutOfGamut);
        }
コード例 #3
0
ファイル: StepPage.xaml.cs プロジェクト: mattlant/RGBDiffLib
        private Color GetColorFromXYY(xyYColour xyy)
        {
            XYZColour xyz   = xyy.ToXYZColour();
            RGBColour rgb   = ColourUtil.XYZTosRGB(xyz);
            Color     color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B);

            return(color);
        }
コード例 #4
0
ファイル: StepPage.aspx.cs プロジェクト: mattlant/RGBDiffLib
        private bool IsOutOfGamut(xyYColour xyy)
        {
            double x = Math.Round(xyy.x, 5, MidpointRounding.ToEven);
            double y = Math.Round(xyy.y, 5, MidpointRounding.ToEven);

            xyYColour temp = xyYColour.FromxyY(x, y, xyy.Y);

            XYZColour xyz = temp.ToXYZColour();
            RGBColour rgb = ColourUtil.XYZTosRGB(xyz);

            return(rgb.OutOfGamut);
        }
コード例 #5
0
ファイル: StepPage.aspx.cs プロジェクト: mattlant/RGBDiffLib
        private Color GetColorFromXYY(xyYColour xyy)
        {
            double x = Math.Round(xyy.x, 5, MidpointRounding.ToEven);
            double y = Math.Round(xyy.y, 5, MidpointRounding.ToEven);

            xyYColour temp = xyYColour.FromxyY(x, y, xyy.Y);

            XYZColour xyz   = temp.ToXYZColour();
            RGBColour rgb   = ColourUtil.XYZTosRGB(xyz);
            Color     color = Color.FromArgb(0, (byte)rgb.R, (byte)rgb.G, (byte)rgb.B);

            return(color);
        }
コード例 #6
0
        public static double GetWeight(RGBColour rgbColourSource, RGBColour rgbColourCompare, ObserverData observerData)
        {
            XYZColour xyzColSource   = ColourUtil.RGBtoXYZ(rgbColourSource);
            xyYColour colAsxyYSource = xyYColour.FromXYZ(xyzColSource);

            XYZColour xyzColCompare   = ColourUtil.RGBtoXYZ(rgbColourCompare);
            xyYColour colAsxyYCompare = xyYColour.FromXYZ(xyzColCompare);

            //****Do calc****
            double angle = ColourUtil.CalcAngle(colAsxyYSource.x, colAsxyYSource.y, colAsxyYCompare.x, colAsxyYCompare.y);


            xyYColour closestObserverSample = GetClosestXy(colAsxyYSource, observerData);

            //NEW BRANCH: Get 3 closest xy colours

            ColourAngleSet angleSet = observerData.ColourData[closestObserverSample];


            return(GetWeightingFactor(closestObserverSample, angle, angleSet, observerData));
        }
コード例 #7
0
        public static double GetWeight2(RGBColour rgbColourSource, RGBColour rgbColourCompare, ObserverData observerData)
        {
            XYZColour xyzColSource   = ColourUtil.RGBtoXYZ(rgbColourSource);
            xyYColour colAsxyYSource = xyYColour.FromXYZ(xyzColSource);

            XYZColour xyzColCompare   = ColourUtil.RGBtoXYZ(rgbColourCompare);
            xyYColour colAsxyYCompare = xyYColour.FromXYZ(xyzColCompare);

            //****Do calc****
            double angle = ColourUtil.CalcAngle(colAsxyYSource.x, colAsxyYSource.y, colAsxyYCompare.x, colAsxyYCompare.y);


            //NEW BRANCH: Get 3 closest xy colours

            IEnumerable <xyYColour> closest3 = Interpolation.GetThreeClosestColours(colAsxyYSource, observerData);

            double influenceA, influenceB, influenceC;

            xyYColour pA = closest3.ElementAt(0);
            xyYColour pB = closest3.ElementAt(1);
            xyYColour pC = closest3.ElementAt(2);

            Interpolation.GetInfluence(colAsxyYSource, pA, pB, pC, out influenceA, out influenceB, out influenceC);

            xyYColour colourAtAngleA = GetClosestAngleColour(observerData.ColourData[pA], angle);
            xyYColour colourAtAngleB = GetClosestAngleColour(observerData.ColourData[pB], angle);
            xyYColour colourAtAngleC = GetClosestAngleColour(observerData.ColourData[pC], angle);

            double distanceA = ColourUtil.Delta3D(pA.x, pA.y, 0, colourAtAngleA.x, colourAtAngleA.y, 0, 8);
            double distanceB = ColourUtil.Delta3D(pB.x, pB.y, 0, colourAtAngleB.x, colourAtAngleB.y, 0, 8);
            double distanceC = ColourUtil.Delta3D(pC.x, pC.y, 0, colourAtAngleC.x, colourAtAngleC.y, 0, 8);

            double interpolatedDistance = Interpolation.GetInterpolatedDistance(distanceA, distanceB, distanceC, influenceA,
                                                                                influenceB, influenceC);

            return(GetWeightingFactor2(interpolatedDistance, observerData));
        }