Main Content

Compare Image Quality Using PSNR

This example shows how to compare the quality of a noisy and denoised image from the PSNR value computed using the PSNR block.

Read an image into the MATLAB workspace.

I = imread('cameraman.tif');

Read the corresponding noisy image into the MATLAB workspace.

noisyI =  imread('noisyCameraman.tif');

Example Model

Open the Simulink model. The model reads the original and the noisy images from the MATLAB workspace and denoises the noisy image by using the Median Filter block.

modelname='ex_blkpsnr.slx';
open_system(modelname);

The model computes the PSNR value for the noisy and the denoised image with respect to the original image and outputs as variables named psnr_noisy and psnr_denoised respectively. The denoised image and the computed PSNR values are exported to the MATLAB workspace.

Simulate and Display Results

Simulate the model.

out = sim(modelname);

Display the noisy image and the corresponding PSNR value

imshow(noisyI,[]);
title(['PSNR = ', num2str(out.psnr_noisy)]);

Display the denoised image and the corresponding PSNR value. The denoised image is of better perceptual quality than the noisy image and hence, has comparatively high PSNR value.

imshow(out.denoisedImage,[]);
title(['PSNR = ', num2str(out.psnr_denoised)]);