Is there a way to detect if an image is blurry?

后端 未结 12 1892
予麋鹿
予麋鹿 2020-11-22 14:48

I was wondering if there is a way to determine if an image is blurry or not by analyzing the image data.

12条回答
  •  执念已碎
    2020-11-22 15:24

    I came up with a totally different solution. I needed to analyse video still frames to find the sharpest one in every (X) frames. This way, I would detect motion blur and/or out of focus images.

    I ended up using Canny Edge detection and I got VERY VERY good results with almost every kind of video (with nikie's method, I had problems with digitalized VHS videos and heavy interlaced videos).

    I optimized the performance by setting a region of interest (ROI) on the original image.

    Using EmguCV :

    //Convert image using Canny
    using (Image imgCanny = imgOrig.Canny(225, 175))
    {
        //Count the number of pixel representing an edge
        int nCountCanny = imgCanny.CountNonzero()[0];
    
        //Compute a sharpness grade:
        //< 1.5 = blurred, in movement
        //de 1.5 à 6 = acceptable
        //> 6 =stable, sharp
        double dSharpness = (nCountCanny * 1000.0 / (imgCanny.Cols * imgCanny.Rows));
    }
    

提交回复
热议问题