public void Render(
            IColorInImageDetection colorInImageDetection,
            ISelectedColorHandle selectedColorHandle,
            IRenderContext renderContext,
            Rectangle rectangle)
        {
            var recogArray = colorInImageDetection.GetUnlockedResultsForColor(selectedColorHandle);

            if (recogArray == null)
            {
                return;
            }

            var color = colorInImageDetection.GetValueForColor(selectedColorHandle);

            var widthScale = (int)Math.Ceiling(rectangle.Width /
                                               (float)recogArray.GetLength(0));
            var heightScale = (int)Math.Ceiling(rectangle.Height /
                                                (float)recogArray.GetLength(1));
            var xx = rectangle.X;
            var yy = rectangle.Y;

            for (var x = 0; x < recogArray.GetLength(0); x++)
            {
                for (var y = 0; y < recogArray.GetLength(1); y++)
                {
                    Color col;
                    var   score = recogArray[x, y] / colorInImageDetection.GetSensitivityForColor(selectedColorHandle);

                    if (score < 0)
                    {
                        var scoreCapped = Math.Min(255, -score);
                        col = new Color(scoreCapped / 255f, scoreCapped / 255f, scoreCapped / 255f, 1f);
                    }
                    else
                    {
                        var scoreCapped = Math.Max(0, score);
                        col = new Color(
                            scoreCapped / 255f * (color.R / 255f),
                            scoreCapped / 255f * (color.G / 255f),
                            scoreCapped / 255f * (color.B / 255f),
                            1f);
                    }

                    _renderUtilities.RenderRectangle(
                        renderContext,
                        new Rectangle(
                            xx + x * widthScale, yy + y * heightScale, widthScale, heightScale),
                        col, true);
                }
            }

            _renderUtilities.RenderText(
                renderContext,
                new Vector2(
                    rectangle.X + rectangle.Width / 2,
                    rectangle.Y + 40),
                "Total " + colorInImageDetection.GetNameForColor(selectedColorHandle) + ": " + colorInImageDetection.GetTotalDetectedForColor(selectedColorHandle),
                _defaultFont);
        }
        private void ProcessorThread()
        {
            while (true)
            {
                try
                {
                    var recogArray = _colorInImageDetection.GetUnlockedResultsForColor(_selectedColorHandle);
                    if (recogArray == null)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    var sensitivity = _colorInImageDetection.GetSensitivityForColor(_selectedColorHandle);

                    var detectedPoints = new List <Vector2>();

                    if (_checkArray == null ||
                        _checkArray.GetLength(0) != recogArray.GetLength(0) ||
                        _checkArray.GetLength(1) != recogArray.GetLength(1))
                    {
                        _checkArray =
                            new bool[recogArray.GetLength(0), recogArray.GetLength(1)];
                    }
                    else
                    {
                        for (var x = 0; x < _checkArray.GetLength(0); x++)
                        {
                            for (var y = 0; y < _checkArray.GetLength(1); y++)
                            {
                                _checkArray[x, y] = false;
                            }
                        }
                    }

                    for (var x = 0; x < recogArray.GetLength(0); x++)
                    {
                        for (var y = 0; y < recogArray.GetLength(1); y++)
                        {
                            var score = recogArray[x, y] / sensitivity;

                            if (score > PointThreshold && !_checkArray[x, y])
                            {
                                if (FloodFillCheckAt(recogArray, _checkArray, x, y))
                                {
                                    detectedPoints.Add(new Vector2(x, y));
                                }
                            }
                        }
                    }

                    DetectedPoints = detectedPoints;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }

                Thread.Sleep(20);
            }
        }