# PSNR calculation with float arrays

The PSNR definition provided by wikipedia is often quoted in discussions regarding PSNR and other similarity metrics.

Essentially the PSNR calculation has two components: the mean squared error and the "maximum possible pixel value of the image" (as per the wikipedia definition).

For arrays (or images) containing 8 bit integer values (e.g. .bmp images), the maximum possible pixel value of the image is 255, since this is the largest 8-bit integer possible.

For arrays (or images) with floating point values (e.g. some .tiff images) the wikipedia definition suggests "the maximum possible pixel value of the image" = 1. Why is this value of 1 chosen?

This would make sense for data that has been min/max normalised, such that the range of the data is 1. However generally, arrays containing floats would not be normalised.

Any insight into what is the generally accepted, correct value for "the maximum possible pixel value of the image" in calculating the PSNR would be appreciated.

Thanks, David

• I think the "1" referred to in Wikipedia is to normalized images, when the maximum is one. in Float values, I don't use PSNR since the maximum is not defined. Unless the problem you are working on has global maximum value. Use MSE or RMSE instead. – Feras Apr 2 '20 at 18:52
• Thanks, I think this is sound advice. MSE and RMSE does not have the same ambiguity as PSNR. Ideally there would be an IEEE (or equivalent) standard for calculating image similarity metrics like PSNR but as far as I know such a thing doesn't exist. – David Lloyd Apr 3 '20 at 19:58
• If you read Wikipedia or sklearn library. If you have float number your maximum is (+1 - (-1)). So R value is 2^2 – Feras Apr 3 '20 at 20:05
• I understand that rationale, although it doesn't say it explicitly on the Wikipedia page for PSNR. It raises a separate question on how best to normalise the float array. Min-max normalisation relies heavily on the values of two entries in the array (the maximum and minimum). This makes it prone to anomalous results if one or both of those two entries happen to be much larger or smaller than the typical values in the array. – David Lloyd Apr 5 '20 at 7:22
• You are right. Normalization plays an important role here. It is a decision should be taken for the quality of your data. What kind of data you are working on ? – Feras Apr 5 '20 at 9:44