// Get pixel color after applying effect to the specified input public static SimpleColor[,] Blur(SimpleColor[,] arr, bool parallel) { int hgt = arr.GetLength(0), wid = arr.GetLength(1); var res = new SimpleColor[hgt, wid]; // The outer for loop can be parallelized, depending on the argument RunForLoop(parallel, 0, hgt, y => { // Leave inner loop sequential for (int x = 0; x < wid; x++) { // Sum colors close to the specified location var sum = SimpleColor.Zero; for (int dy = -2; dy <= 2; dy++) for (int dx = -2; dx <= 2; dx++) sum += CheckedRead(arr, y + dy, x + dx, hgt, wid); res[y, x] = sum / 25; } }); return res; }