问题
I want to detect how blurred an image is, may be It can be called "blur extend". I found a useful paper for this:
http://www.cs.cmu.edu/~htong/pdf/ICME04_tong.pdf
I used OpenCV and implemented all steps from this paper, but the result is not same as result from this paper.
Can someone give me any advise for detecting "blur extend"?
回答1:
You can detect a blurring image with using next algorithm:
- Convert the image into gray format.
Calculate the maximal absolute second derivative from the gray image (for every point):
d[x,y] = max(abs(2*d[x,y] - d[x,y+1] -d[x,y-1]), abs(2*d[x,y] - d[x+1,y] -d[x-1,y]));
Calculate the histogram of this estimated image (maximal absolute second derivative).
Find the upper quantile (0,999) of this histogram.
If this value is less than the threshold (about 25% from image dynamic range), then the image is blurred.
If you want to estimate a blur value, perform steps 2-5 for reduced image.
You can write these algorithms on their own or use one from the implementation of Simd Library (disclaimer: I'm the author).
Simd::BgrToGray
orSimd::BgraToGray
(for step 1).Simd::AbsSecondDerivativeHistogram
(for steps 2-5).Simd::ReduceGray2x2
(for step 6).
回答2:
The answer of Ermlg looks close to best, but in code way in this way I achieved it.
The score below 100 was giving me somewhat blury images.
# applying fast fourier transform to fin d the blur images , taken threshold to be 100 but it can vary
import cv2
def variance_of_laplacian(frame_path):
# compute the Laplacian of the image and then return the focus
# measure, which is simply the variance of the Laplacian
image = cv2.imread(frame_path)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
return cv2.Laplacian(gray, cv2.CV_64F).var()
Source of method was from adrian rosebrock
来源:https://stackoverflow.com/questions/19443908/detecting-how-blurred-an-image-is