Mean filter for smoothing images in Matlab

后端 未结 5 1971
后悔当初
后悔当初 2020-12-30 04:12

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

5条回答
  •  天涯浪人
    2020-12-30 04:47

    I see good answers have already been given, but I thought it might be nice to just give a way to perform mean filtering in MATLAB using no special functions or toolboxes. This is also very good for understanding exactly how the process works as you are required to explicitly set the convolution kernel. The mean filter kernel is fortunately very easy:

    I = imread(...)
    kernel = ones(3, 3) / 9; % 3x3 mean kernel
    J = conv2(I, kernel, 'same'); % Convolve keeping size of I
    

    Note that for colour images you would have to apply this to each of the channels in the image.

提交回复
热议问题