public double GetDifference(AvgColor color1, AvgColor color2)
        {
            var redMass = (color1.RAvg + color2.RAvg)/2;
            var deltaRed = color1.RAvg - color2.RAvg;
            var deltaGreen = color1.GAvg - color2.GAvg;
            var deltaBlue = color1.BAvg - color2.BAvg;

            return Math.Sqrt(Math.Pow(deltaRed, 2) + Math.Pow(deltaGreen, 2) + Math.Pow(deltaBlue, 2));

            /*
                        return Math.Sqrt((2 + redMass / 256) * Math.Pow(deltaRed, 2) + 4 * Math.Pow(deltaGreen, 2) +
                                      (2 + (255 - redMass) / 256) * Math.Pow(deltaBlue, 2));
            */
        }
        public double GetDifferenceUsingCie1976Comparison(AvgColor color1, AvgColor color2)
        {
            var colorRgb1 = new Rgb() {R = color1.RAvg, G = color1.GAvg, B = color1.BAvg};
            var colorRgb2 = new Rgb() {R = color2.RAvg, G = color2.GAvg, B = color2.BAvg};

            return _comparer.Compare(colorRgb1, colorRgb2);
        }
        public TileInfo FindTitle(AvgColor avgColor)
        {
            var threshold = 1;
            TileInfo result = null;
            var hitMatch = false;

            while (result == null)
            {
                hitMatch = false;
                foreach (var title in TileContainer.TileBase)
                {
                    if (GetDifferenceUsingCie1976Comparison(title.Value.AvgColor, avgColor) <= threshold)
                    {
                        // if we use title, then go next
                        if (_usedTiles.Contains(title.Key))
                        {
                            hitMatch = true;
                            continue;
                        }

                        result = title.Value;
                        _usedTiles.Add(title.Key);
                        break;
                    }
                }

                var oldThreshold = threshold;

                if (result == null)
                {
                    if (hitMatch)
                    {
                        foreach (var title in TileContainer.TileBase)
                        {
                            if (!_usedTiles.Contains(title.Key) && GetDifferenceUsingCie1976Comparison(title.Value.AvgColor, avgColor) <= threshold + 5)
                            {
                                result = title.Value;
                                _usedTiles.Add(title.Key);
                                break;
                            }
                        }
                    }

                    if (result == null)
                    {
                        threshold = oldThreshold;
                        var _usedTitlesCopy = _usedTiles.ToList();

                        foreach (var usedTile in _usedTitlesCopy)
                        {
                            var title = TileContainer.TileBase[usedTile];
                            if (GetDifferenceUsingCie1976Comparison(title.AvgColor, avgColor) <= threshold)
                            {
                                result = title;
                                break;
                            }
                        }
                    }
                }

                threshold += 2;
            }

            return result;
        }