What does negative value of PSNR indicate?

54 views (last 30 days)
I am computing the PSNR value between an image and its filtered version and getting a negative value.
I understand tht since there is log, if the number is less than 1, I will be getting a negative value.
But what does the negative value actually imply??

Accepted Answer

Raunak Gupta
Raunak Gupta on 14 Nov 2020
Hi,
According to the definition of PSNR as mentioned here , it cannot be negative. You can check if the range in both images is same as in if both images are of datatype unit8 then range should be [0,255]. Also, if you are converting one image to be in range [0,1] and the other image is in range [0,255] then this behavior can occur. Finally, if you are using your own implementation for psnr then I would suggest using built-in function psnr for calculating the same.
The only reason I can think of is a big mismatch between the range of values in the image.
Hope this helps!
  9 Comments
Sushma TV
Sushma TV on 17 Nov 2020
Ok..Will check out..Thanks again..
Sushma TV
Sushma TV on 23 Nov 2020
@ Raunak, I think the error in the computation of PSNR is due to the difference in the range of the values as you had mentioned earlier.
In my code, I read an image that is uint8 and the max value it can take is 255. When I convert it to double, the range of the variable changes between 0 to 1.
Then I am computing wavelet coefficients, w1 using an inbuilt function. The wavelet coefficients are of type double and I expected the values to lie between 0 and 1. However, one of the subbands have a maximum value equal to 330. Why is this so?
I am then computing the PSNR between the orginal image and the image obtained after transformation by using the formula for PSNR rather than the inbuilt function, I am first computing the MSE as below, where I convert both the original and the filtered images to double as shown below
squaredErrorImage1 = (double(Input_img) - double(Filtered_Img)) .^ 2;
double(Input_img) - has values between 0 and 1
double(Filtered_Img) - has values beyond 255 (maximum value is around 330).
Shouldn't the double(Filtered_Img) also have a value between 0 and 1.
The error in the PSNR value is because of this variation. How can it be overcome?
How can we keep track of the range of value of the variable at each stage?

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 14 Nov 2020
  1 Comment
Sushma TV
Sushma TV on 17 Nov 2020
Further to the same question, I used the formula of PSNR instead of the inbuilt function as below
PSNR1 = 10 * log10( 255^2 / mse1); where
mse1 = mean square error computed as
squaredErrorImage1 = (double(Input_img) - double(Filtered_Img)) .^ 2;
mse1 = sum(sum(squaredErrorImage1)) / (r1 * c1); where
r1,c1 = row and col size of the input image and boht the input and filtererd image are of type double
Hope I am right..
I am getting a positive value using this formula but a negative value using the inbuilt function of matlab 'psnr'
Can you please help me figure out why there is a difference between the two?

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!