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; }
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)); }
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)); }