openCV与C++的图像识别(二)——pHash

这篇博客探讨了使用OpenCV和C++实现图像识别的过程,特别是通过pHash算法中的离散余弦变换(DCT)系数进行图像比较。尽管结果不是非常理想,但该方法仍具有一定的参考价值。
摘要由CSDN通过智能技术生成
/*

参考博客:https://blog.csdn.net/akadiao/article/details/79779634
配置环境参考:https://blog.csdn.net/qq_28584889/article/details/87914831

*/

#include <iostream>
#include <bitset>
#include <string>
#include <iomanip>
#include <cmath>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2\core\core.hpp>
 
using namespace std;
using namespace cv;
 
#define PI 3.1415926
#define hashLength 64
 
/*
	功能:获取DCT系数
	n:矩阵大小
	quotient: 系数
	quotientT: 系数转置
*/
void coefficient(const int &n, double **quotient, double **quotientT){
	double sqr = 1.0/sqrt(n+0.0);
	for(int i = 0; i < n; i++){
		quotient[0][i] = sqr;
		quotientT[i][0] =  sqr;
	}
 
	for(int i = 1; i < n; i++){
		for(int j = 0; j < n; j++){
			quotient[i][j] = sqrt(2.0/n)*cos(i*(j+0.5)*PI/n);  // 由公式得到
			quotientT[j
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值