protected override void PixelCrossing(PixelCollection pixelCollection, int pixelsToSelect, int howManyChildren) { int deadPixelIndex = pixelsToSelect; lock (pixelCollection) { foreach (var pixelPair in _pixelPairs) { for (int i = 0; i < howManyChildren; i++) { var newPixel = new Pixel() { Blue = Average(pixelPair.First.Blue, pixelPair.Second.Blue), Green = Average(pixelPair.First.Green, pixelPair.Second.Green), Red = Average(pixelPair.First.Red, pixelPair.Second.Red), Alpha = byte.MaxValue, IndexColumn = pixelCollection[deadPixelIndex].IndexColumn, IndexRow = pixelCollection[deadPixelIndex].IndexRow, IndexGlobal = pixelCollection[deadPixelIndex].IndexGlobal, RankingPoints = 0, }; pixelCollection[deadPixelIndex] = newPixel; deadPixelIndex++; } } pixelCollection.OrderAscending(); } return; }
public PixelCollection Execute(PixelCollection pixelCollection, IScoringTable scoringTable, int pixelsToSelect) { lock (pixelCollection) { pixelCollection.OrderByBlue(); pixelCollection.AddPointsToValues(scoringTable); pixelCollection.OrderByGreen(); pixelCollection.AddPointsToValues(scoringTable); pixelCollection.OrderByRed(); pixelCollection.AddPointsToValues(scoringTable); pixelCollection.RemoveWeakPixels(pixelsToSelect); pixelCollection.OrderAscending(); } return(pixelCollection); }