Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Remove Noise from Color Image Using Pretrained Neural Network

This example shows how to remove Gaussian noise from an RGB image. Convert the noisy image to the L*a*b* color space, and remove noise on the luminance channel L* by using a pretrained denoising neural network.

In practice, image color channels frequently have correlated noise. You will have better denoising results if you train a denoising network on color images. For more information, see Train and Apply Denoising Neural Networks.

Read a color image into the workspace and convert the data to type double. Display the image.

RGB = imread('lighthouse.png');
RGB = im2double(RGB);

figure
imshow(RGB)
title('Pristine Image')

Add Gaussian noise with a variance of 0.01 to the image. imnoise adds noise to each color channel independently. Display the noisy image.

noisyRGB = imnoise(RGB,'gaussian',0,0.01);

figure
imshow(noisyRGB)
title('Noisy Image')

Load the pretrained denoising neural network.

net = denoisingNetwork('dncnn');

Convert the image to the L*a*b* color space.

LAB = rgb2lab(RGB);

Noise is primarily in the luminance channel. Remove the noise from this channel only, by using the pretrained denoising neural network.

LAB(:,:,1) = denoiseImage(LAB(:,:,1),net);

Convert the image back to the RGB color space.

denoisedRGB = lab2rgb(LAB);

Display the denoised image.

figure
imshow(denoisedRGB)
title('Denoised Image')

Calculate the peak signal-to-noise ratio (PSNR) for the noisy and denoised images. A larger PSNR indicates that noise has a smaller relative signal, and is associated with higher image quality.

noisyPSNR = psnr(noisyRGB,RGB);
fprintf('\n The PSNR value of the noisy image is %0.4f.',noisyPSNR);
 The PSNR value of the noisy image is 20.6395.
denoisedPSNR = psnr(denoisedRGB,RGB);
fprintf('\n The PSNR value of the denoised image is %0.4f.',denoisedPSNR);
 The PSNR value of the denoised image is 53.7825.

Calculate the structural similarity (SSIM) index for the noisy and denoised images. An SSIM index close to 1 indicates good agreement with the reference image, and higher image quality.

noisySSIM = ssim(noisyRGB,RGB);
fprintf('\n The SSIM value of the noisy image is %0.4f.',noisySSIM);
 The SSIM value of the noisy image is 0.7393.
denoisedSSIM = ssim(denoisedRGB,RGB);
fprintf('\n The SSIM value of the denoised image is %0.4f.',denoisedSSIM);
 The SSIM value of the denoised image is 0.9999.

See Also

Related Topics

Was this topic helpful?