我想知道是否有一种方法可以通过分析图像数据来确定图像是否模糊。
当前回答
在高度重视的期刊(IEEE Transactions on Image Processing)上发表的两种方法的Matlab代码可在这里获得:https://ivulab.asu.edu/software
检查CPBDM和JNBM算法。如果你检查代码,它并不难移植,顺便说一下,它是基于Marzialiano的方法作为基本特征。
其他回答
在高度重视的期刊(IEEE Transactions on Image Processing)上发表的两种方法的Matlab代码可在这里获得:https://ivulab.asu.edu/software
检查CPBDM和JNBM算法。如果你检查代码,它并不难移植,顺便说一下,它是基于Marzialiano的方法作为基本特征。
我想到了一个完全不同的解决方案。 我需要分析视频静止帧,以便在每(X)帧中找到最清晰的帧。这样,我将检测运动模糊和/或失焦图像。
我最终使用了Canny边缘检测,我得到了非常非常好的结果,几乎每一种视频(与尼基的方法,我有数字化的VHS视频和沉重的交错视频的问题)。
我通过在原始图像上设置感兴趣区域(ROI)来优化性能。
使用EmguCV:
//Convert image using Canny
using (Image<Gray, byte> 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));
}
这就是我在Opencv中检测区域焦点质量的方法:
Mat grad;
int scale = 1;
int delta = 0;
int ddepth = CV_8U;
Mat grad_x, grad_y;
Mat abs_grad_x, abs_grad_y;
/// Gradient X
Sobel(matFromSensor, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT);
/// Gradient Y
Sobel(matFromSensor, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT);
convertScaleAbs(grad_x, abs_grad_x);
convertScaleAbs(grad_y, abs_grad_y);
addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad);
cv::Scalar mu, sigma;
cv::meanStdDev(grad, /* mean */ mu, /*stdev*/ sigma);
focusMeasure = mu.val[0] * mu.val[0];
上面的回答阐明了许多事情,但我认为做一个概念上的区分是有用的。
如果你对一个模糊的图像拍摄一张完美对焦的照片呢?
The blurring detection problem is only well posed when you have a reference. If you need to design, e.g., an auto-focus system, you compare a sequence of images taken with different degrees of blurring, or smoothing, and you try to find the point of minimum blurring within this set. I other words you need to cross reference the various images using one of the techniques illustrated above (basically--with various possible levels of refinement in the approach--looking for the one image with the highest high-frequency content).
谢谢妮基的拉普拉斯建议。 OpenCV文档给我指出了同样的方向: 使用python, cv2 (opencv 2.4.10)和numpy…
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
numpy.max(cv2.convertScaleAbs(cv2.Laplacian(gray, 3)))
结果在0-255之间。我发现任何超过200的东西都非常清晰,而到了100,就明显模糊了。Max从来没有真正低于20,即使它完全模糊。
推荐文章
- 使用ImageMagick“Diff”图像
- 如何使用pip安装opencv ?
- 如何用OpenCV2.0和Python2.6调整图像大小
- 如何消除数独方块的凹凸缺陷?
- ImportError: numpy.core.multiarray导入失败
- 我如何量化两幅图像之间的差异?
- 有没有办法检测图像是否模糊?
- 简单和快速的方法来比较图像的相似性
- 如何合并一个透明的png图像与另一个图像使用PIL
- 提取和保存视频帧
- 如何使用c#裁剪图像?
- 什么是最好的java图像处理库/方法?
- 给出一个图像来表示和解决一个迷宫
- 如何通过Conda安装Python OpenCV ?
- 推荐使用ImageMagick压缩JPG文件