How to denoise an image

17 visualizaciones (últimos 30 días)
Maaz Madha
Maaz Madha el 3 de Dic. de 2021
Comentada: DGM el 3 de Dic. de 2021
I am trying to denoise an image and so far have done this
As a res
I = imread('noise1.png.png');
II=imread('Original.jpg');
%J=rgb2gray(I);
J=im2gray(I);
figure(1);
imhist(I);
ylim([0 1*10^4])
figure(2)
imhist(II)
ylim([0 1*10^4])
%% Median filter
average_1=fspecial('average',[3,3]);
filtered_image2=imfilter(I(250:end),average_1);
figure(5)
imhist(filtered_image2)
ylim([0 1*10^4])
%% Gaussian filter
G=imgaussfilt3(filtered_image2);%(I_filtered);
figure(4)
imhist(G)
ylim([0 1*10^4])
figure(5)
imshow(G)
%% Sharpening an image
% b=imsharpen(KK);
% figure(6)
% imhist(b)
% ylim([0 1*10^4])
% figure(7)
% imshow(b)
As a result, my processed image is (first_filter) but it is still not good and I wanted to know what I am doing wrong or how can I better improve it to come as close to the original.

Respuesta aceptada

DGM
DGM el 3 de Dic. de 2021
This isn't a median filter. It's an average filter, and it's working on some arbitrary vectorized section of the image. Applying a 2D filter to a vector isn't going to accomplish anything of use here.
average_1=fspecial('average',[3,3]);
filtered_image2=imfilter(I(250:end),average_1);
If you want to do median filtering, try doing median filtering.
noisypict = imread('noise1.png');
% Median filter
fs = 10;
medfiltpict = zeros(size(noisypict),class(noisypict));
for c = 1:size(noisypict,3)
% medfilt2() can't handle RGB
medfiltpict(:,:,c) = medfilt2(noisypict(:,:,c),[fs fs]);
end
imshow(noisypict)
imshow(medfiltpict)
  2 comentarios
Maaz Madha
Maaz Madha el 3 de Dic. de 2021
Thank you for your answer. Is it possible to increase the resolution of the image as it has become very blurred in contrast to the original one(as according to my understanding median filters are very useful for removing outliers in images which there was a lot of in this case)
DGM
DGM el 3 de Dic. de 2021
Increasing the resolution isn't going to get you anything other than a bigger blurry image. You can try to mess around with imsharpen() to recover some edge emphasis, but I doubt that's going to be much help. You can try to use weiner2() instead of medfilt2().
The image looks like it's been upscaled about 400% after the noise was added, so you'll have to bear in mind that the information it represents is commensurate with a very tiny image.
% start with a clean image instead of an upscaled screenshot
cleanpict = imread('onion.png');
noisypict = imnoise(cleanpict,'gaussian',0,0.005);
% Median filter
fs = 4;
outpict = zeros(size(noisypict),class(noisypict));
for c = 1:size(noisypict,3)
outpict(:,:,c) = medfilt2(noisypict(:,:,c),[fs fs]);
%outpict(:,:,c) = wiener2(noisypict(:,:,c),[fs fs]); % maybe mess with a weiner filter instead
end
outpict = imsharpen(outpict); % maybe mess with that
imshow(outpict)

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by