MATLAB: Apply a Local Averaging Mask

image processingImage Processing Toolbox

How can you apply a 3×3 local averaging mask to enhance the sharpness in an image. How can you set the mask? I'd like to get a better understanding in how this method of filtering an image works and how to compute the algorithm.

Best Answer

Local averaging:
conv(double(YourImage), ones(3,3)/9, 'same')
ones(3,3)/9 is not usually the mask used for sharpening. You tend to sharpen horizontally and vertically separately, using a mask such as [0, 1, 0; -1 0 -1; 0 1 0]