opencv 图片清晰度判断代码
读取D盘里面的两张图片,进行清晰度的判别。
阈值可以自行修改
#include <highgui/highgui.hpp>
#include <imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat imageSource = imread("D:/1.jpg");
Mat imageGrey;
cvtColor(imageSource, imageGrey, CV_RGB2GRAY);
Mat imageSobel;
Sobel(imageGrey, imageSobel, CV_16U, 1, 1);
//图像的平均灰度