Back to problems

Apply a 2D Box Blur Filter

Algorithm · Apple · Medium

Problem Given a grayscale image matrix img, produce a 3×3 box blur by replacing each interior pixel with the floor of the average of its 3×3 neighborhood. Only pixels that are not on the outer boundary are part of the result: use rows 1..H-2 and columns 1..W-2. Boundary pixels must not be included in the output. Input The first line contains two integers H W. Each of the following H lines contains W pixel-intensity integers. Output Print the blurred interior matrix, which…

Checking your access…