当前位置:网站首页>Opencv image sharpness evaluation (camera autofocus)
Opencv image sharpness evaluation (camera autofocus)
2022-07-29 02:07:00 【Mubai 001】
Recently, I want to realize camera auto focusing , That is, image sharpness evaluation is required , Search on the Internet .
The first good article is : Sharpness evaluation method without reference image
http://nkwavelet.blog.163.com/blog/static/227756038201461532247117
This is a very detailed introduction to the theory or formula , share 16 A calculation method , It's worth learning .
(1)Brenner Gradient function
(2)Tenengrad Gradient function
(3)Laplacian Gradient function
(4)SMD( Gray variance ) function
...
Next is fuzzy detection , Noise detection , Combination of noise and blur
The article pays attention to theory , There is no specific sample program . There is a result comparison chart .
The second good article is :OpenCV Image sharpness evaluation ( Camera autofocus )
https://blog.csdn.net/dcrmg/article/details/53543341
The implementation of the first three methods in this set , this 3 It's in opencv All have function implementation . Realization 3 Three kinds of sharpness evaluation methods , Namely Tenengrad Gradient method 、Laplacian Gradient method and variance method .
Tenengrad Gradient method , The measurement index is through Sobel The average gray value of the image processed by the operator , The bigger the value is. , Represents the sharper the image .Sobel function .
Laplacian Gradient method : ditto , But with Laplacian function
Variance method : Variance is used in probability theory to examine a set of discrete data and its expectations ( That is, the mean value of the data ) The separation between ( deviate ) Measurement method of degree . The variance is large , It means that the deviation between this group of data is large , Some of the data in the group are large , Some are smaller , It's not evenly distributed ; Variance is small , It means that the deviation between this group of data is small , The data in the group is evenly distributed , Similar in size . The greater the variance , It means the better the clarity .
This sample program is available for reference .
The code of the first algorithm is as follows ( The second is to write off some differences ):
#include <highgui/highgui.hpp>
#include <imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat imageSource = imread("2.jpg");
Mat imageGrey;
cvtColor(imageSource, imageGrey, CV_RGB2GRAY);
Mat imageSobel;
Sobel(imageGrey, imageSobel, CV_16U, 1, 1);
//Laplacian(imageGrey, imageSobel, CV_16U); Algorithm 2
// The average gray level of the image
double meanValue = 0.0;
meanValue = mean(imageSobel)[0];
//double to string
stringstream meanValueStream;
string meanValueString;
meanValueStream << meanValue;
meanValueStream >> meanValueString;
meanValueString = "Articulation(Sobel Method): " + meanValueString;
putText(imageSource, meanValueString, Point(20, 50), CV_FONT_HERSHEY_COMPLEX, 0.8, Scalar(255, 255, 25), 2);
imshow("Articulation", imageSource);
waitKey();
}
The evaluation value here is meanValue , The larger the value, the clearer .// double to string Part is just added to the figure to show .
The difference in variance calculation is :
// Find the standard deviation of gray image
meanStdDev(imageGrey, meanValueImage, meanStdValueImage);
double meanValue = 0.0;
meanValue = meanStdValueImage.at<double>(0, 0);
It is also mentioned that :
In industrial applications , The clearest focusing image is not necessarily the best , There may be molars ( Water ripple ) The phenomenon , Generally, you need to make a fine adjustment in the attachment of the clearest focusing position .
边栏推荐
- FPGA实现10M多功能信号发生器
- How companies make business decisions -- with the help of data-driven marketing
- Ciscn 2022 central China Misc
- 12.< tag-动态规划和子序列, 子数组>lt.72. 编辑距离
- The basic concept of transaction and the implementation principle of MySQL transaction
- StoneDB 邀请您参与开源社区月会!
- Mathematical modeling -- heat conduction of subgrade on Permafrost
- (arxiv-2018) reexamine the time modeling of person Reid based on video
- IDEA 连接 数据库
- Number of consecutive subarrays with leetcode/ and K
猜你喜欢

druid. io kill -9 index_ Realtime traceability task

Implementation of 10m multifunctional signal generator with FPGA

Add graceful annotations to latex formula; "Data science" interview questions collection of RI Gai; College Students' computer self-study guide; Personal firewall; Cutting edge materials / papers | sh

How to find the right agent type? Multi angle analysis for you!

Introduction to shared data center agent

LM13丨形态量化-动量周期分析

Stonedb invites you to participate in the open source community monthly meeting!

ASCII code table
![[golang] use select {}](/img/30/fa593ec682a40c47689c1fd88f9b83.png)
[golang] use select {}
![[the road of Exile - Chapter 8]](/img/df/a801da27f5064a1729be326c4167fe.png)
[the road of Exile - Chapter 8]
随机推荐
在Qt中如何编写插件,加载插件和卸载插件
Leetcode exercise - Sword finger offer 45. arrange the array into the smallest number
Comprehensive analysis of news capture doorway
控制输入框弹出弹窗 和不弹出窗口
[golang] use select {}
Mysql存储json格式数据
Have you ever encountered the situation that the IP is blocked when crawling web pages?
使用POI,实现excel文件导出,图片url导出文件,图片和excel文件导出压缩包
The growth path of embedded engineers
Lm13 morphological quantification momentum period analysis
Tda75610-i2c-determination of I2C address of analog power amplifier
Sigma-DSP-OUTPUT
Solution of Lenovo notebook camera unable to open
ciscn 2022 华中赛区 misc
Wonderful use of data analysis
(CVPR-2019)选择性的内核网络
The number of consecutive subarrays whose leetcode/ product is less than k
表单校验 隐藏的输入框 显示才校验
[7.21-26] code source - [square count] [dictionary order minimum] [Z-type matrix]
Establish an engineering template based on STM32 in keil -- detailed steps