使用OpenCvSharp检测图像模糊存在误判,请求代码审核
图像模糊检测代码调试求助
我首次使用OpenCvSharp实现图像模糊检测功能,但部分实际模糊的图像被判定为清晰。烦请审核以下代码,确认我对OpenCvSharp的使用是否正确:
public static bool IsBlurry(string imagePath, double threshold = 100.0) { // Load the image var image = Cv2.ImRead(imagePath, ImreadModes.Grayscale); // Compute the Laplacian of the image var laplacian = new Mat(); Cv2.Laplacian(image, laplacian, MatType.CV_64F); // Compute the variance of Laplacian Cv2.MeanStdDev(laplacian, out _, out var stddev); var varianceValue = stddev.Val0 * stddev.Val0; // Variance = standard deviation squared // Check if the image is blurred return varianceValue < threshold; }
参考图片:


感谢您的帮助。
内容的提问来源于stack exchange,提问作者Sandeep Reddy Pinniti
相关产品推荐
相关产品推荐

