public bool isCellIlluminated(IPixelReadable image, int x, int y, float blackBrightnessLowerBound, float blackBrightnessUpperBound, int plusMinusSpread, int brightnessErrorCount)
    {
        var cellColor        = image.getPixel(x, y);
        var cellColorPlus    = image.getPixel(x + plusMinusSpread, y);
        var cellColorMinus   = image.getPixel(x - plusMinusSpread, y);
        var upCellColorPlus  = image.getPixel(x, y + plusMinusSpread);
        var upCellColorMinus = image.getPixel(x, y - plusMinusSpread);
        var brightness       = cellBrightness(cellColor);
        var brightness2      = cellBrightness(cellColorPlus);
        var brightness3      = cellBrightness(cellColorMinus);
        var brightness4      = cellBrightness(upCellColorMinus);
        var brightness5      = cellBrightness(upCellColorMinus);
        int brightnessCount  = 0;

        brightnessCount += (brightness <blackBrightnessLowerBound || brightness> blackBrightnessUpperBound) ? 0 : 1;
        brightnessCount += (brightness2 <blackBrightnessLowerBound || brightness2> blackBrightnessUpperBound) ? 0 : 1;
        brightnessCount += (brightness3 <blackBrightnessLowerBound || brightness3> blackBrightnessUpperBound) ? 0 : 1;
        brightnessCount += (brightness4 <blackBrightnessLowerBound || brightness4> blackBrightnessUpperBound) ? 0 : 1;
        brightnessCount += (brightness5 <blackBrightnessLowerBound || brightness5> blackBrightnessUpperBound) ? 0 : 1;
        if (brightnessCount < brightnessErrorCount || y > 971)//allow 2 errors, 971 is height of top row
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
    public List <int> getUpNextColors(IPixelReadable image, int topX, int topY, int topX2, int topY2, int cellHeight, int rowCount, int secondSquareHeightOffset, int secondSquareHeightOffset2)
    {
        var retr = new List <int>();
        //get top one
        int     yPixelPos1 = (topY);
        int     yPixelPos2 = (yPixelPos1 + secondSquareHeightOffset);
        Color32 cell1Color = image.getPixel(topX, 1080 - yPixelPos1);
        Color32 cell2Color = image.getPixel(topX, 1080 - yPixelPos2);
        int     color1Name = getClosestColor(cell1Color);
        int     color2Name = getClosestColor(cell2Color);

        if (color1Name == -1 && color2Name == -1)
        {
            retr.Add(-1);
        }
        else if (color1Name == -1)
        {
            retr.Add(color2Name);
        }
        else if (color2Name == -1)
        {
            retr.Add(color1Name);
        }
        else
        {
            retr.Add(color1Name);
        }
        //get rest
        for (int y = 0; y < rowCount; y++)
        {
            yPixelPos1 = (topY2 + cellHeight * y);
            yPixelPos2 = (yPixelPos1 + secondSquareHeightOffset2);
            cell1Color = image.getPixel(topX2, 1080 - yPixelPos1);
            cell2Color = image.getPixel(topX2, 1080 - yPixelPos2);
            color1Name = getClosestColor(cell1Color);
            color2Name = getClosestColor(cell2Color);
            if (color1Name == -1 && color2Name == -1)
            {
                retr.Add(-1);
            }
            else if (color1Name == -1)
            {
                retr.Add(color2Name);
            }
            else if (color2Name == -1)
            {
                retr.Add(color1Name);
            }
            else
            {
                retr.Add(color1Name);
            }
        }
        return(retr);
    }