How would you implement a simple box blur on a grayscale image?

WHAT IT TESTS: Spatial convolution and image filtering basics. ANSWER OUTLINE: Iterate interior pixels, sum the N by N neighborhood, divide by kernel area, write to a new buffer. RED FLAG: In place updates that blur already blurred values.
WHAT IT TESTS: Whether you understand spatial domain linear filtering and can translate a kernel into a concrete nested loop algorithm without library calls. ANSWER OUTLINE: Allocate a separate output image; for each interior pixel, accumulate the N by N neighborhood sum, divide by kernel area, and store; handle borders by skipping or mirroring. RED FLAG: Describing an in place update where blurred values leak into subsequent sums, or treating the kernel as arbitrary weights instead of a uniform average.
Read the original → Wikipedia: Box blur
- #computer vision
- #image processing
- #convolution
- #spatial filtering
- #algorithms
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.