I have a 512 × 512 gray scale image that I converted to a matrix whose values are between 0 and 1. The value 0 represents black and the value 1 represents white and intermediate values are gray scale values.
I need to implement a one-dimensional M-point averaging filter to this image for M = 11, M = 31, M = 61, such that each pixel value is replaced by the equal-weighted average of its (M − 1)/2 neighbors to its left, (M − 1)/2 neighbors to its right, and the pixel value itself. For instance, for M = 3, it would be like:
The averaging is one-dimensional (1D), that is, along only one of the dimensions (horizontal dimension). Assume that values lying outside of the image are zero while averaging.
Can someone help out with this? Thanks.