need code for weight median filter for de-noising of a gray scale image

2 views (last 30 days)
here is an image but i couldn't get a valid code on net the code that i found iy didnt give me back a gray scale image with removed noise but the output of those code is too dark so hope i'll get some help here
so attaching the image here and waiting for response

Answers (2)

Image Analyst
Image Analyst on 13 Feb 2014
Did you try
filteredImage = medfilt2(grayImage, [9, 9]);
??? Exactly what code did you find or not find, or run? Did it give you an output image at all (even if it was dark) or not? Your statement is not clear.
  2 Comments
Filza Ashraf
Filza Ashraf on 14 Feb 2014
i have been using this code
I = imread('p1.png');
I = double (I);
Z = imnoise(I,'salt & pepper',0.02);
a = double(Z);
b = a;
W = [1,1,1; 1,1,1; 1,1,1]/9;
[row col] = size(a);
for x = 2:1:row-1
for y = 2:1:col-1
a1 = [W(1)*a(x-1,y-1) W(2)*a(x-1,y) W(3)*a(x-1,y+1) ... W(4)*a(x,y-1) W(5)*a(x,y) W(6)*a(x,y+1)... W(7)*a(x+1,y-1) W(8)*a(x+1,y) W(9)*a(x+1,y+1)];
a2 = sort(a1);
med = a2(5);
b(x,y) = med;
end
end
figure(3); imshow(uint8(b)); figure(4); imshow(uint8(Z));

Sign in to comment.


sairahul thota
sairahul thota on 18 Feb 2018
sir i need code for the removal of salt and pepper noise in image using adaptive median filter

Community Treasure Hunt

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

Start Hunting!