Beispiel #1
0
        private void LoadData()
        {
            _colourData = new Dictionary <xyYColour, ColourAngleSet>();


            var meta = new LinqMetaData();


            //We get all control colours that are not set to skip
            IQueryable <ControlSetColourEntity> controlCOlours = from col in meta.ControlSetColour
                                                                 where col.Skip == false
                                                                 select col;

            foreach (ControlSetColourEntity controlSetColourEntity in controlCOlours)
            {
                //Create an xyY Colour
                xyYColour xyYControlCOlour = xyYColour.FromxyY(controlSetColourEntity.XyY_x, controlSetColourEntity.XyY_y,
                                                               controlSetColourEntity.XyY_YY);

                ColourAngleSet angleSet = GetEachAvgAngle(xyYControlCOlour);

                _colourData.Add(xyYControlCOlour, angleSet);
            }

            CalculateMinMaxRange();
        }
Beispiel #2
0
        public static ColourAngleSet GetEachAvgAngle(xyYColour colour)
        {
            ColourAngleSet avgColours = new ColourAngleSet();

            IEnumerable <IGrouping <double, ObserverDataSetColourEntity> > colAngleGroups = GetAngleGroupsForColour(colour);

            foreach (var colAngleGroup in colAngleGroups)
            {
                double x = 0, y = 0, Y = colour.Y;
                int    colourCount = colAngleGroup.Count();


                foreach (ObserverDataSetColourEntity colourEntity in colAngleGroup)
                {
                    x += colourEntity.XyY_x;
                    y += colourEntity.XyY_y;
                }

                x = x / colourCount;
                y = y / colourCount;
                xyYColour newAvg = xyYColour.FromxyY(x, y, Y);
                avgColours.Add(colAngleGroup.Key, newAvg);
            }

            return(avgColours);
        }
Beispiel #3
0
        public static xyYColour GetClosestAngleColour(ColourAngleSet angleSet, double angle)
        {
            xyYColour closestAngleColour = null;

            //TODO: Increase accuracy only if this whole colour system seems to be working
            foreach (var colourAtAngle in angleSet)
            {
                if (ColourUtil.Delta(angle, colourAtAngle.Key) <= 45)
                {
                    closestAngleColour = colourAtAngle.Value;
                }
            }
            return(closestAngleColour);
        }
Beispiel #4
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));
        }
Beispiel #5
0
        public static double GetWeightingFactor(xyYColour xyYControlCol,
                                                double angle,
                                                ColourAngleSet angleSet, ObserverData observerData)
        {
            //Get the closest angle
            xyYColour closestAngleColour = null;

            //TODO: Increase accuracy only if this whole colour system seems to be working
            foreach (var colourAtAngle in angleSet)
            {
                if (ColourUtil.Delta(angle, colourAtAngle.Key) < 45)
                {
                    closestAngleColour = colourAtAngle.Value;
                }
            }

            double realDeltaDIff = ColourUtil.Delta3D(closestAngleColour.x, closestAngleColour.y, 0,
                                                      xyYControlCol.x, xyYControlCol.y, 0, 4);

            return(1 / (realDeltaDIff / observerData.AverageRange));
        }