Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to detect if a image is blurred in few cases #1666

Open
SandeepReddyPinniti opened this issue Apr 25, 2024 · 0 comments
Open

Unable to detect if a image is blurred in few cases #1666

SandeepReddyPinniti opened this issue Apr 25, 2024 · 0 comments

Comments

@SandeepReddyPinniti
Copy link

Summary of your issue

Hi, 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 image for reference. Please review my code and let me know if I have used OpenCvSharp correctly.

Environment

Windows 10 Machine, Using C#

Example code:

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;

}

Output:

paste your output

What did you intend to be?

Accurately detect if the image is blurred.
download (2)
download
photo-1485288734756-0b31a0a31d95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant