File Exchange

image thumbnail

Averaging Filter without using imfilter

version 1.1 (1.28 KB) by

Filters the image nicely without using imfilter

9 Ratings



View License

put the image in your current directory and change the name of your image in the code.

run the code
will ask you to input the value of averaging mask.

enter 3 if you want to use 3*3
enter 5 if you want to use 5*5

thats it.

Comments and Ratings (11)

Jan Mentink

Hashim Shafiq


hello simon...
i have compared the result with inbuilt matlab function for averaging.
and the code is developed according to the basic concept of averaging filter.
so i didn't find any fault or error although the result was quite nice.

if you have made a code in your own logic then i will be happy to see it.
thank you

Jan Simon

Jan Simon (view profile)

I do not think that "round(median())" matches "without using built-in functions.
The brute clearing header "clc; clear all; close all;" removes all functions from the memory, such that reloading wastes much time, and all breakpoints of the debugger are clear also. But it is a really bad idea to prevent debugging conceptionally.

Using "sum" as name of a variable leads to errors frequently, when the user wants to use the function with the same name. Therefore it is recommended not to shadow built-in functions.

It would be much more useful for others, if the code is written as a function and the parameters and data are provided as input arguments. Using INPUT in a script is not convenient and not usable in productive code. Using "ans" to provide a result is a bad idea, because this is overwritten by the last not caught output of any function. Therefore the result can change unexpectedly during debugging.

For educational purposes, applying Matlab's vectorized methods would be much more valuable and substantially faster. Without a documentation and any comments in the code, modifications demands for guessing what the code should achieve.

My conclusion: This is neither useful nor usable in productive code, nor helpful for eductaional purposes.


conv2 is the inbuilt function but here logic implemented without any inbuilt function.
so i calculated each coefficient without using inbuilt functions.


Anon (view profile)

refer to the function conv2 to be much more efficient in calculating an averaging filter.



updated as a toolbox

MATLAB Release
MATLAB 8.0 (R2012b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video