File size: 2,118 Bytes
5037842
33d1544
 
 
 
5fa5172
5037842
33d1544
5037842
 
 
 
33d1544
 
9fd6c68
33d1544
 
9fd6c68
 
 
 
 
 
 
 
 
 
33d1544
 
 
9fd6c68
 
 
 
 
 
 
 
33d1544
 
 
9fd6c68
 
 
 
 
 
33d1544
9fd6c68
33d1544
9fd6c68
 
33d1544
9fd6c68
33d1544
9fd6c68
 
 
 
 
33d1544
 
 
 
9fd6c68
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: Peak Signal to Noise Ratio
tags:
- evaluate
- metric
description: "Image quality metric"
sdk: gradio
sdk_version: 3.0.2
app_file: app.py
pinned: false
---

# Metric Card for Peak Signal to Noise Ratio



## Metric Description
It is the ratio between the maximum possible power of a signal and the power of
corrupting noise that affects the fidelity of its representation. This metric is
commonly used to measure the quality of images generated by models.

- Super-Resolution 
- Image Denoising
- Image Compression

PSNR is a measure of the quality of reconstruction of an image. The higher the PSNR, the
better the quality of the image.

## How to Use

At minimum, this metric requires predictions and references as inputs.

```python
import evaluate

psnr = evaluate.load("jpxkqx/peak_signal_to_noise_ratio")
psnr.compute(predictions=[[0.0, 0.1], [0.1, 0.9]], references=[[0.0, 0.2], [0.1, 0.8]])
```

### Inputs

- **predictions** *('np.array'): Predictions to evaluate.*
- **references** *('np.array'): True image to consider as baseline.*
- **data_range** *('float'): The data range of the images (distance between the minimum
and maximum possible values). If not provided, it is determined from the image data-type.*
- **sample_weight** *('list'): Sample weights default to None.*


### Output Values

- **psnr** *('float'): Peak Signal to Noise Ratio, which it is expressed as a
logarithmic quantity using the decibel scale.*

Outputs example:

```python
{'psnr': 35.23}
```
Typical values for the PSNR in lossy image and video compression are between 30 and 50
dB, provided the bit depth is 8 bits. 



## Further References


[Peak Signal to Noise Ratio (PSNR) - Wikipedia](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio)
[Peak Signal to Noise Ratio (PSNR) - scikit-image](https://scikit-image.org/docs/dev/api/skimage.metrics.html#skimage.metrics.peak_signal_noise_ratio)
[Peak Signal to Noise Ratio (PSNR) - PyTorch](https://pytorch.org/ignite/generated/ignite.metrics.PSNR.html)
[Peak Signal to Noise Ratio (PSNR) - TensorFlow](https://www.tensorflow.org/api_docs/python/tf/image/psnr)