Search code examples
matlabgaussiannoise

Matlab remove noise


I want to remove noise from an image. The image i've been given is a .mat file but it's very complicated because when i load the mat file no image can be seen, then i use imwrite to make it jpg

imwrite(destroyedImg, 'fr.jpg');

But when i use imshow I get only colorful dots in white background!

Is there a way to find out how to clear the noise from this picture?! I'm not allowed to use the internal functions but to build one myself! But i cannot figure out the kind of noise and then remove it! i also have to return the "clear image" in RGB format and not grayscale!

here is some of my code

clear all; close all; 
load('image_destroyed.mat');
imwrite(image_destroyed, 'fraou.jpg');
img = imread('fraou.jpg'); 
subplot(2,2,1), imshow(img)
title('Fraou');
H = fspecial('average',[3 3]);
average = imfilter(img, H, 'replicate');
subplot(2,2,2), imshow(average);
title('average');H = fspecial('gaussian',[5 5]);
average = imfilter(img, H, 'replicate');
subplot(2,2,3); imshow(average);title('gaussian');
H = wiener2(img,[5 5]);
subplot(2,2,4); imshow(H)
title('wiener 5x5');

Here is the pisture i get in the first place


Solution

  • DO NOT USE imwrite to 'jpg' to get your image - this only introduces artifacts.
    Your input image is of type double with values exceeding the range [0..1] and thus all the confusion.

    load('image_destroyed.mat');
    image_destroyed = image_destroyed / 255.0; % back to [0..1] range
    imshow( image_destroyed ); % should be meaningful now.