I have an original image and a distorted image of the original one. I want to calculate the PSNR of the distorted image, so that I can measure the distortion in dB. Image type is colored jpeg. I embeded a watermark in RGB color image now i want to calculate PSNR and MSE of original and watermarked images. How can i find PSNR and MSE of original and watermarked images 2 Comments. Find the treasures in MATLAB Central and discover how the community can help you!
Compute peak signal-to-noise ratio (PSNR) between images
Description
The PSNR block computes the peak signal-to-noise ratio, in decibels, between two images. This ratio is used as a quality measurement between the original and a compressed image. The higher the PSNR, the better the quality of the compressed, or reconstructed image.
The mean-square error (MSE) and the peak signal-to-noise ratio (PSNR) are used to compare image compression quality. The MSE represents the cumulative squared error between the compressed and the original image, whereas PSNR represents a measure of the peak error. The lower the value of MSE, the lower the error.
To compute the PSNR, the block first calculates the mean-squared error using the following equation:
In the previous equation, M and N are the number of rows and columns in the input images. Then the block computes the PSNR using the following equation:
In the previous equation, R is the maximum fluctuation in the input image data type. For example, if the input image has a double-precision floating-point data type, then R is 1. If it has an 8-bit unsigned integer data type, R is 255, etc.
Computing PSNR for Color Images
Different approaches exist for computing the PSNR of a color image. Because the human eye is most sensitive to luma information, you can compute the PSNR for color images by converting the image to a color space that separates the intensity (luma) channel, such as YCbCr. The Y (luma), in YCbCr represents a weighted average of R, G, and B. G is given the most weight, again because the human eye perceives it most easily. Compute the PSNR only on the luma channel.
Input
Input image, specified as scalar, vector, or matrix.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Input image, specified as scalar, vector, or matrix.
Psnr Calculation
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Output
Peak signal-to-noise ratio between images, returned as a scalar.
Dependencies
If the input is a fixed-point or integer data type, the block output is double-precision floating point. Otherwise, the block input and output are the same data type.
Data Types: double
Model Examples
Compare the quality of a noisy and denoised image from the PSNR value computed using the PSNR
block.
Block Characteristics
Data Types |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Generates code only for double
or single
data types.
Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.
Evaluation of PSNR Lin Zhang, Dept. Computing, The Hong Kong Polytechnic University |
Introduction
PSNR (Peak Singal-to-Noise Ratio) index is a traditional IQA metric.
Source Code
We used the PSNR implementation provided by Dr. Zhou Wang, which can be downloaded here https://ece.uwaterloo.ca/~z70wang/research/iwssim/psnr_mse.m.
Usage Notes
1. This implementation can only deal with gray-scale images. So, you need to convert the RGB image to the grayscale version, which can be accomplished by rgb2gray in Matlab.
Evaluation Results
The results (in Matlab .mat format) are provided here. Each result file contains a n by 2 matrix, where n denotes the number of distorted images in the database. The first column is the PSNR values, and the second column is the mos/dmos values provided by the database. For example, you can use the following matlab code to calculate the SROCC and KROCC values for PSNR values obtained on the TID2008 database:
%%%%%%%%%%%%%%%
matData = load('PSNROnTID.mat');
PSNROnTID= matData.PSNROnTID;
PSNR_TID_SROCC = corr(PSNROnTID(:,1), PSNROnTID(:,2), 'type', 'spearman');
PSNR_TID_KROCC = corr(PSNROnTID(:,1), PSNROnTID(:,2), 'type', 'kendall');
%%%%%%%%%%%%%%%
The source codes to calculate the PLCC and RMSE are also provided for each database. This needs a nonlinear regression procedure which is dependant on the initialization of the parameters. We try to adjust the parameters to get a high PLCC value. For different databases, the parameter initialization may be different. The nonlinear fitting function is of the form as described in [1].
Evaluation results of PSNR on seven databases are given below. Besides, for each evaluation metric, we present its weighted-average value over all the testing datasets; and the weight for each database is set as the number of distorted images in that dataset.
Database | Results | Nonlinear fitting code | SROCC | KROCC | PLCC | RMSE |
TID2008 | PSNROnTID | NonlinearFittingTID | 0.5531 | 0.4027 | 0.5734 | 1.0994 |
CSIQ | PSNROnCSIQ | NonlinearFittingCSIQ | 0.8058 | 0.6084 | 0.8000 | 0.1575 |
LIVE | PSNROnLIVE | NonlinearFittingLIVE | 0.8756 | 0.6865 | 0.8723 | 13.3597 |
IVC | NonlinearFittingIVC | 0.6884 | 0.5218 | 0.7196 | 0.8460 | |
Toyama-MICT | 0.6132 | 0.4443 | 0.6429 | 0.9585 | ||
A57 | 0.6189 | 0.4309 | 0.7073 | 0.1737 | ||
WIQ | 0.6257 | 0.4626 | 0.7939 | 14.1381 | ||
Weighted-Average | 0.6874 | 0.5161 | 0.7020 |
Matlab For Mac Student
Reference
Python Psnr
[1] H.R. Sheikh, M.F. Sabir, and A.C. Bovik, 'A statistical evaluation of recent full reference image quality assessment algorithms', IEEE Trans. on Image Processing, vol. 15, no. 11, pp. 3440-3451, 2006.
Psnr Calculation In Matlab For Mac Free
Created on: May. 08, 2011
Last update: Aug. 04, 2011