根据王鸿南论文中的方法实现《图像清晰度评价方法研究 》
《图像清晰度评价方法研究 》
跟求梯度没什么区别,只不过是换了一个模板
double PVA_Grad(Mat &img)
{
double P = 0;
for (int i = 1; i < img.rows - 1; i++)
{
//定义行指针
uchar *current_ptr = (uchar*)img.data + i * img.cols;
uchar *pre_ptr = (uchar*)img.data + (i - 1)*img.cols;
uchar *next_ptr = (uchar*)img.data + (i + 1)*img.cols;
for (int j = 1; j < img.cols - 1; j++)
{
P += abs((pre_ptr[j - 1] - current_ptr[j])*0.7 + pre_ptr[j] - current_ptr[j] + (pre_ptr[j + 1] - current_ptr[j])*0.7
+ (current_ptr[j - 1] - current_ptr[j]) + current_ptr[j + 1] - current_ptr[j]
+ (next_ptr[j - 1] - current_ptr[j])*0.7 + next_ptr[j] - current_ptr[j] + (next_ptr[j + 1] - current_ptr[j])*0.7);
}
}
return P/ (img.cols - 2) / (img.rows - 2);
}