Apply a mean filter on a matrix

Illustration
Abigail - 2020-07-17T13:03:43+00:00
Question: Apply a mean filter on a matrix

How can i apply a mean or laplacian or average or any kind of filters 3x3 on any matrix i give it to it and get the new matrix ? What is the code for it

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

How about imfilter()

 

filterWindow = ones(3) / 9;
filteredImage = imfilter(m, filterWindow);

Or for the Laplacian, how about conv2():

filterWindow = -1 * ones(3);
filterWindow = 8;
filteredImage = conv2(m, filterWindow, 'same');


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!