How to denoise an image

조회 수: 38 (최근 30일)
Maaz Madha
Maaz Madha 2021년 12월 3일
댓글: DGM 2021년 12월 3일
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.

채택된 답변

DGM
DGM 2021년 12월 3일
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
Maaz Madha
Maaz Madha 2021년 12월 3일
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 2021년 12월 3일
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)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by