Adaptative filter problem with Matlab
Show older comments
Hello everybody
I am a trying to implement an adaptative filter, to filter images after adding a certain noise (Gaussian, Speckel, or Salt & Pepper). I have implemented a code, but after running the programm, I do not obtain the expected result. The code also contains some part that are not relevant here, the function is in adaptativefilter.m This adaptative filter is an adaptative average filter on a 3*3 neigborhood, represented by : I'(s) = sum(c*I(p))/sum(c) with c=1 if I(s)-I(p)<tau and 0 otherwise. I really do not see where this results come from! My image is too black to be just!
If someone can help me it will be really nice! Have a nice day
Answers (1)
Hmh. Well. I don't know what to do with this on the forum, so I'll just attach it. Both files have been fixed. Here's a short extract:
% read an image
inpict = imread('cameraman.tif');
% add gaussian noise
G = imnoise(inpict,'gaussian',0, 0.005);
% calculate error of noisy image
GaussianMSE = immse(inpict,G)
% Average filter
averagefilter = fspecial('average',3);
averageG = imfilter(G,averagefilter,'replicate');
G_MSE_average = immse(inpict,averageG)
% Adaptive filter
tau = 0.25;
adaptiveG = adaptfilter(G,tau);
G_MSE_adaptive = immse(inpict,adaptiveG)
% Median filter
medianG = medfilt2(G,[3 3]);
G_MSE_median = immse(inpict,medianG)
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!