Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the code for computing PSNR is wrong #86

Closed
Delicious-Bitter-Melon opened this issue Feb 10, 2024 · 4 comments
Closed

the code for computing PSNR is wrong #86

Delicious-Bitter-Melon opened this issue Feb 10, 2024 · 4 comments

Comments

@Delicious-Bitter-Melon
Copy link

Your code computing PSNR as follows is wrong:

mse = np.mean((original - compressed) ** 2)
.

The accurate code is mse = np.mean((original/1.0 - compressed/1.0) ** 2), because original and compressed images are uint8 in your code, and (original - compressed) * * 2 will cause numerical overflow.

@Delicious-Bitter-Melon
Copy link
Author

Please update your results in the paper.

@Wangt-CN
Copy link
Owner

Could you please check the formal implementatoin here: https://github.com/bonlime/pytorch-tools/blob/master/pytorch_tools/metrics/psnr.py#L11
The input range is [0,255]

@Delicious-Bitter-Melon
Copy link
Author

Could you please check the formal implementatoin here: https://github.com/bonlime/pytorch-tools/blob/master/pytorch_tools/metrics/psnr.py#L11 The input range is [0,255]

image

The author claims in the issues that they have not used and even tested PSNR and SSIM.

@Delicious-Bitter-Melon
Copy link
Author

Delicious-Bitter-Melon commented Feb 13, 2024

https://github.com/bonlime/pytorch-tools/blob/01f40fe75c2a11683c247d8fcf3d3645a5783441/tests/metrics/test_metric.py#L105
image
And their images are float32, but in your codes images are uint8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants