M-point averaging filter to an image

1 vue (au cours des 30 derniers jours)
Sarah Maas
Sarah Maas le 17 Avr 2021
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:
y[n,m]= 1/3(x[n,m1]+x[n,m]+x[n,m+1])
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.

Réponses (1)

Bjorn Gustavsson
Bjorn Gustavsson le 17 Avr 2021
Read the help and documentation for conv2.
HTH

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by