List <int> GetPatternOccurenceFromMaskedArea(WaveCollapseHistoryElement wfc, PatternFromSampleElement patterns, Color[,] masked, Color black)
        {
            //var x = wfc.
            var x             = patterns.Patterns;
            var superposition = wfc.Superpositions;

            // List of pattern
            List <int> goodPatternsOccurence = new List <int>();

            // Fill list with zeros
            for (int i = 0; i < x.Count; i++)
            {
                goodPatternsOccurence.Add(0);
            }

            for (int i = 0; i < superposition.GetLength(0); i++)
            {
                for (int j = 0; j < superposition.GetLength(1); j++)
                {
                    if (masked[i, j] == black)
                    {
                        int index = superposition[i, j].collapsedIndex;
                        goodPatternsOccurence[index]++;
                    }
                }
            }

            return(goodPatternsOccurence);
        }
        Superposition[,] RemoveNoiseFromImage(WaveCollapseHistoryElement wfc, PatternFromSampleElement p)
        {
            var patterns = p.Patterns;
            // Original image superpositions
            var superpositions = wfc.Superpositions;

            // Create new copied superpositions[,].
            Superposition[,] superpositionsWithoutNoise = NewCopiedSuperposition(superpositions, patterns);

            // Find superposition to replace once colorful cells should be changed to empty.
            Superposition emptySuperpositiontoReplace = FindEmptySuperpositionToReplace(superpositions, patterns);

            RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 2, 1);
            RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 1, 1);
            RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 2, 1);
            RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 1, 1);
            //RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 2, 1);
            //RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 1, 1);
            //RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 2, 1);
            //RemoveSingleCells(ref superpositionsWithoutNoise, superpositions, emptySuperpositiontoReplace, 1, 1);


            return(superpositionsWithoutNoise);
        }