Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int GetError(IPictureMutation mutation)
- {
- var picture = mutation.ApplyToPicture(algorithm.CurrentPicture);
- var donePixels = new bool[algorithm.SourceData.Width,algorithm.SourceData.Height];
- var totalError = 0;
- totalError += ScorePolygons(donePixels, picture);
- totalError += ScoreRemainingPixels(donePixels);
- return totalError;
- }
- int ScoreRemainingPixels(bool[,] donePixels)
- {
- return algorithm.SourceData.GetPoints().Where(point => !donePixels[point.X, point.Y]).Sum(point => algorithm.SourceData[point].Length);
- }
- int ScorePolygons(bool[,] donePixels, VectorPicture picture)
- {
- var totalError = 0;
- foreach (var polygon in picture.Polygons.ReverseEnumerable())
- {
- foreach (var point in drawer(polygon).Where(point => !donePixels[point.X, point.Y]))
- {
- donePixels[point.X, point.Y] = true;
- totalError += algorithm.SourceData[point].GetAbsColorError(polygon.Color);
- }
- }
- return totalError;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement