python 实现图像的峰值信噪比 源代码
时间: 2024-04-29 22:24:58 浏览: 111
可以使用以下代码实现图像的峰值信噪比:
```python
import cv2
import numpy as np
# 读入图片
img = cv2.imread('image.jpg')
# 计算峰值信噪比
peak_signal = np.max(img)
noise = img - np.mean(img)
noise_signal = np.linalg.norm(noise)
psnr = 20 * np.log10(peak_signal / noise_signal)
print("图像的峰值信噪比为:", psnr, "dB")
```
注意,上面的代码仅适用于灰度图像。对于彩色图像,需要先将其转换为灰度图像。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)