当前位置:网站首页>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 .
边栏推荐
- Qt源码分析--QObject(4)
- MPEG音频编码三十年
- [7.21-26] code source - [sports festival] [Dan fishing war] [maximum weight division]
- mobile-picker.js
- Leetcode exercise - Sword finger offer 45. arrange the array into the smallest number
- 2022年编程语言排名,官方数据来了,让人大开眼界
- LM13丨形态量化-动量周期分析
- LeetCode 练习——剑指 Offer 45. 把数组排成最小的数
- 给LaTeX公式添加优美的注解;日更『数据科学』面试题集锦;大学生『计算机』自学指南;个人防火墙;前沿资料/论文 | ShowMeAI资讯日报
- What is browser fingerprint recognition
猜你喜欢

(cvpr-2019) selective kernel network

(arxiv-2018) reexamine the time modeling of person Reid based on video

数学建模——仓内拣货优化问题

Web crawler API Quick Start Guide

Sigma-DSP-OUTPUT

Leetcode exercise - Sword finger offer 45. arrange the array into the smallest number

StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?

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

Establish an engineering template based on STM32 in keil -- detailed steps

How companies make business decisions -- with the help of data-driven marketing
随机推荐
Mysql存储json格式数据
Covering access to 2w+ traffic monitoring equipment, EMQ creates a new engine for the digitalization of all elements of traffic in Shenzhen
Lua third-party byte stream serialization and deserialization module --lpack
[10:00 public class]: application exploration of Kwai gpu/fpga/asic heterogeneous platform
Leetcode/ and continuous shortest subarray greater than or equal to target
MPEG音频编码三十年
Stonedb invites you to participate in the open source community monthly meeting!
Qt 内存管理小技巧
As long as I run fast enough, it won't catch me. How does a high school student achieve a 70% salary increase under the epidemic?
Planning mathematics final simulation exam I
【流放之路-第五章】
Process -- user address space and kernel address space
(CVPR-2019)选择性的内核网络
The basic concept of transaction and the implementation principle of MySQL transaction
How to prevent all kinds of affiliated fraud?
【公开课预告】:快手GPU/FPGA/ASIC异构平台的应用探索
Secret skill winter tide branding skill matching
秘术冬潮烙技能搭配
LM13丨形态量化-动量周期分析
How to find the right agent type? Multi angle analysis for you!