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

1 回表示 (過去 30 日間)
Filza Ashraf
Filza Ashraf 2014 年 2 月 13 日
コメント済み: Image Analyst 2018 年 2 月 18 日
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

回答 (2 件)

Image Analyst
Image Analyst 2014 年 2 月 13 日
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 件のコメント
Filza Ashraf
Filza Ashraf 2014 年 2 月 14 日
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));
Image Analyst
Image Analyst 2014 年 2 月 14 日
Try
imshow(uint8(b), []);

サインインしてコメントする。


sairahul thota
sairahul thota 2018 年 2 月 18 日
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!

Translated by