image filtering with median need basic help

2 views (last 30 days)
Jhangir
Jhangir on 6 Nov 2013
Edited: Image Analyst on 6 Nov 2013
Im trying to filter an image and remove surrounding noise, I need BASIC code which will help me do this. I have an image X, I separated X into three 2 dimensional arrays [R,G,B], Now i have the following
[nrows,mcols]=size(R);
for n=2:1:(nrows-1)
for m=2:1:(ncols-1)
I want to filter every value in each of the three matrices except for the ones in the corner, thus you will see my for statement starting 1 unit ahead and 1 unit behind on the other end. I want to filter each pixel like a tic tac toe. Each pixel is surrounded by 8 other pixels, I want to find the median of all the pixels including the middle one and then save the median and assign it to I dont know because my teacher never told us how to filter images. So yea...

Answers (2)

Jhangir
Jhangir on 6 Nov 2013
help pls

Image Analyst
Image Analyst on 6 Nov 2013
Edited: Image Analyst on 6 Nov 2013
% Call median filter function:
filteredImageR = medfilt2(redChannel, [7, 7]);
filteredImageG = medfilt2(greenChannel, [7, 7]);
filteredImageB = medfilt2(blueChannel, [7, 7]);
Also, see attached demo.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!