计算图像的清晰度 [英] Calculating sharpness of an image
问题描述
我在互联网上发现拉普拉斯方法是一种非常好的计算图像清晰度的技术.我试图在opencv 2.4.10中实现它.应用拉普拉斯函数后如何获得清晰度测量?下面是代码:
I found on the internet that laplacian method is quite good technique to compute the sharpness of a image. I was trying to implement it in opencv 2.4.10. How can I get the sharpness measure after applying the Laplacian function? Below is the code:
Mat src_gray, dst;
int kernel_size = 3;
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
/// Convert the image to grayscale
cvtColor( src, src_gray, CV_RGB2GRAY );
/// Apply Laplace function
Mat abs_dst;
Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
//compute sharpness
??
有人可以指导我吗?
推荐答案
可能的副本:所以您的重点衡量指标是:
so your focus measure is:
cv::Laplacian(src_gray, dst, CV_64F);
cv::Scalar mu, sigma;
cv::meanStdDev(dst, mu, sigma);
double focusMeasure = sigma.val[0] * sigma.val[0];
编辑#1 :
好的,因此期望聚焦良好的图像具有更锐利的边缘,因此使用图像渐变有助于确定可靠的聚焦度量.在给定图像梯度的情况下,焦点度量必须将每个点处的数据作为唯一值合并.
Okay, so a well focused image is expected to have sharper edges, so the use of image gradients are instrumental in order to determine a reliable focus measure. Given an image gradient, the focus measure have to pool the data at each point as an unique value.
使用二阶导数是一种用于传递与尖锐边缘相关的高空间频率的技术.作为第二个导数运算符,我们使用拉普拉斯算子,可以使用掩码进行近似计算:
The use of second derivatives is one technique for passing the high spatial frequencies, which are associated with sharp edges. As a second derivative operator we use the Laplacian operator, that can be approximate using the mask:
在每个点上集中数据,我们使用两种方法.第一个是所有绝对值的总和,得出以下焦点度量:
Foor pooling the data at each point, we use two methods. The first one is the sum of all the absolute values, driving to the following focus measure:
其中,L(m, n)
是输入图像I(m, n)
与掩码L
的卷积.第二种方法计算绝对值的方差,从而提供新的焦点测度,其值如下:
where L(m, n)
is the convolution of the input image I(m, n)
with the mask L
. The second method calculates the variance of the absolute values, providing a new focus measure given by:
其中L
上划线是绝对值的平均值.
where L
overline is the mean of absolute values.
阅读文章
J.L. Pech-Pacheco,G.Cristobal,J.Chamorro-Martinez,J. 费尔南德斯·瓦尔迪维亚(Fernandez-Valdivia),"硅藻自动聚焦在明场显微镜中的应用: 比较研究",第15届国际模式会议 表彰奖,2000年.(第3卷)
J.L. Pech-Pacheco, G. Cristobal, J. Chamorro-Martinez, J. Fernandez-Valdivia, "Diatom autofocusing in brightfield microscopy: a comparative study", 15th International Conference on Pattern Recognition, 2000. (Volume:3 )
了解更多信息.
这篇关于计算图像的清晰度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!