I have used OpenCvSharp for the first time. I’m using it to find out if an image is blurred or not. Some of the images are blurred but my code is returning that the image is not blurred. Attached images for reference. Please review my code and let me know if I have used OpenCvSharp correctly
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;
}
Thanks in advance.