Sheldon
Sheldon

Reputation: 3

removing salt and pepper noise using wiener filter in matlab

How do I restore an RGB image which has salt&pepper filter applied using Wiener filter in Matlab? Here is my code

image=imread('1.jpg');
sandpimage = imnoise(image, 'salt & pepper', 0.05);

I guess I have to use deconvwnr function but it requires a second parameter PSF to be given

Upvotes: 0

Views: 1934

Answers (1)

Lincoln Cheng
Lincoln Cheng

Reputation: 2303

Apply the filter separately to each color layer (R, G, B):

sandpimage_filtered = sandpimage;

for layer=1:3
    sandpimage_filtered(:,:,layer) = wiener2(sandpimage(:,:,layer), [5 5]);
end

%//plot the images to see the difference
subplot(2,1,1)
imshow(sandpimage)
subplot(2,1,2)
imshow(sandpimage_filtered)

In the above code I am using a window size of 5x5. You can change the window size inside the wiener2 function

Upvotes: 1

Related Questions