Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mean filter for smoothing images in Matlab

I need to test some basic image processing techniques in Matlab. I need to test and compare especially two types of filters: mean filter and median filter.

To smooth image using median filtering, there is a great function medfilt2 from image processing toolbox. Is there any similar function for mean filter? Or how to use the filter2 function to create the mean filter?

One of the most important things for me is to have the possibility of setting radius of the filter. I.e. for median filter, if I want the [3 x 3] radius (mask), I just use

imSmoothed = medfilt2(img, [3 3]);

I would like to achieve something similar for mean filter.

like image 357
Gacek Avatar asked Nov 15 '09 16:11

Gacek


People also ask

How do you apply a mean filter to an image in MATLAB?

h = fspecial('average', n); filter2(h, img); See doc fspecial : h = fspecial('average', n) returns an averaging filter. n is a 1-by-2 vector specifying the number of rows and columns in h .

What is mean filter in image processing?

Mean filtering is a simple, intuitive and easy to implement method of smoothing images, i.e. reducing the amount of intensity variation between one pixel and the next. It is often used to reduce noise in images.

What do you mean by smoothing filter?

Smoothing Spatial Filter: Smoothing filter is used for blurring and noise reduction in the image. Blurring is pre-processing steps for removal of small details and Noise Reduction is accomplished by blurring.


1 Answers

h = fspecial('average', n);
filter2(h, img);

See doc fspecial: h = fspecial('average', n) returns an averaging filter. n is a 1-by-2 vector specifying the number of rows and columns in h.

like image 199
rcs Avatar answered Oct 11 '22 11:10

rcs