当前位置:网站首页>图像评价方法程序-PSNR
图像评价方法程序-PSNR
2022-08-08 06:20:00 【开门大弟子】
本文主要展示图像的有参考评价方式PSNR的程序部分,其数学原理部分参考这片文章。
以下为主程序部分:
#include "common.h"
int main() {
Mat img1 = imread("图片地址");
Mat img2 = imread("图片地址");
getPSNR(img1, img2);
return 0;
}
以下部分是PSNR函数部分:
#include "common.h"
void getPSNR(const Mat& img1, const Mat& img2)
{
Mat temp;
absdiff(img1, img2, temp); // |I1 - I2|AbsDiff函数是 OpenCV 中计算两个数组差的绝对值的函数
temp.convertTo(temp, CV_32F); // 这里我们使用的CV_32F来计算,因为8位无符号char是不能进行平方计算
temp = temp.mul(temp); // |I1 - I2|^2
Scalar temp_sum = sum(temp); //对每一个通道进行加和
double sse = temp_sum.val[0] + temp_sum.val[1] + temp_sum.val[2]; // sum channels
if( sse <= 1e-10) // 对于非常小的值我们将约等于0
cout << "两张图像一样" <<endl;
else
{
double MSE =sse /(double)(img1.channels() * img1.total());//计算MSE
cout << "MSE: " << MSE << endl;
double PSNR = 10.0*log10((255*255)/MSE);
cout << "PSNR:" << PSNR<< endl;
}
}
以下是头文件:
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
using namespace std;
void getPSNR(const Mat& img1, const Mat& img2);
边栏推荐
- 【笔记工具】
- plt.axis(‘tight‘) 的含义
- 基于knn的手写数字识别
- Rust学习:5_所有权与借用
- 神经网络参数量和计算量,神经网络是参数模型吗
- 独立成分分析ICA/FastICA
- 卷积神经网络的基本操作,卷积神经网络卷积计算
- Several postman features worth collecting will help you do more with less!
- How to batch import files and rename them all to the same file name
- Educational Codeforces Round 133 (Rated for Div. 2) C补题
猜你喜欢

flex布局缺点

APISIX Ingress v1.5-rc1 发布

The amount of parameters and calculation of neural network, is the neural network a parametric model?

Maykle Studio - Deep Learning - BP Neural Network

What does the "busy" Polkadot latest effort mean for DOT investors?

Day8:面试必考编程题(细心OJ)

卷积神经网络 图像识别,卷积神经网络 图像处理

Promise的使用与async/await的使用

cnn卷积神经网络反向传播,卷积神经网络维度变化

快要“金九银十”了,你开始准备了吗?
随机推荐
神经网络一般训练多少次,神经网络训练时间过长
Tensorboard的使用 ---- SummaryWriter类(pytorch版)
Web Application Vulnerability Assessment with Zap and W3af
Graphical LeetCode - 636. Exclusive Time of Functions (Difficulty: Moderate)
“忙碌”的 Polkadot最新努力,对DOT投资者意味着什么?
plt.axis(‘tight‘) 的含义
Sentinel流控规则绑定nacos持久化
Day7:面试必考选择题
Introduction to uvm
【微信小程序】一文学懂小程序的数据绑定和事件绑定
tkinter-TinUI-xml实战(7)PDF分页与合并
The use of Promise and the use of async/await
cnn卷积神经网络反向传播,卷积神经网络维度变化
独立成分分析ICA/FastICA
Runtime - KVC, KVO principle
Horizontal version of the generated image uniapp H5 signature
2-SAT
2021 mathematical modeling national competition question B
Maykle Studio - Deep Learning - BP Neural Network
人体神经元细胞分布图片,神经元人体分布大图