Blur a grayscale float image on the GPU: each output pixel is the average of the 3 x 3 neighborhood around it, counting only the neighbors that lie inside the image.
So an interior pixel averages 9 values, a pixel on an edge 6, a corner 4, and on a 1-pixel-wide image fewer still. Both images are row-major: pixel is at index r * width + c.
Complete:
__global__ kernel on a 2D grid, one thread per output pixel (x = column, y = row), that reads its neighbors directly from global memory and divides the sum by the number of neighbors it actually used.void box_blur(const float* in, float* out, int width, int height) with host pointers. Allocate, copy in, launch, copy back and free. out must be a separate buffer: never blur in place. width, height . Do not write a main() in your solution.