Square-Neighborhood Image Blur
Problem statement
For each grayscale pixel, consider all other in-bounds cells within row and column distance radius. Floor the neighbor mean, then floor the average of that mean and the original pixel. Preserve a pixel with no neighbors.
Return a new matrix using only original-image values for every calculation.
Function
blurImage(image: int[][], radius: int) → int[][]Examples
Example 1
image = [[9,6],[3,0]]radius = 1return = [[6,5],[4,3]]Each pixel sees the other three cells.
Example 2
image = [[7]]radius = 0return = [[7]]The only pixel has no neighbor.
Constraints
1 <= rows,columns <= 5000 <= pixel <= 2550 <= radius <= 500