当前位置:网站首页>OpenCV获取和设置图像的平均亮度
OpenCV获取和设置图像的平均亮度
2022-08-04 05:24:00 【superchao1982】
1. OpenCV1.0中C方式:
double getAvg(IplImage *img)
{
IplImage *gray = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1);
cvCvtColor(img,gray,CV_RGB2GRAY);
CvScalar scalar = cvAvg(gray);
cvReleaseImage(&gray);
return scalar.val[0];
}
void setAvg(IplImage *img,IplImage *out,double avg_gray)
{
double prev_avg_gray = get_avg_gray(img);
cvConvertScale(img,out,avg_gray/prev_avg_gray);
}
2. OpenCV2.0中C++方式:
double getAvg(Mat img)
{
Mat gray;
cvtColor(img, gray, CV_RGB2GRAY);
Scalar scalar = mean(gray);
return scalar.val[0];
}
void setAvg(Mat scr,Mat dst, double avg)
{
double fpreAvg = getAvg(scr);
scr.convertTo(dst,scr.type(),avg/fpreAvg);
}
边栏推荐
- Delphi-C端有趣的菜单操作界面设计
- The difference between px, em, and rem
- 商城App开发都有哪些功能呢
- 数的划分之动态规划
- 4.3 Annotation-based declarative transactions and XML-based declarative transactions
- 【云原生--Kubernetes】Pod资源管理与探针检测
- 7.18 Day23----标记语言
- What are the functions of mall App development?
- 商城系统APP如何开发 都有哪些步骤
- Summary of MySQL database interview questions (2022 latest version)
猜你喜欢

SLSA 框架与软件供应链安全防护

Get the selected content of the radio box

What is the salary of a software testing student?

4.3 Annotation-based declarative transactions and XML-based declarative transactions

【云原生--Kubernetes】Pod资源管理与探针检测
![[Evaluation model] Topsis method (pros and cons distance method)](/img/e7/c24241faced567f3e93f6ff3f20074.png)
[Evaluation model] Topsis method (pros and cons distance method)

一个对象引用的思考

腾讯136道高级岗面试题:多线程+算法+Redis+JVM
![[Cocos 3.5.2]开启模型合批](/img/d9/9e8f71c9a26c8052b11291fe3ba7ac.png)
[Cocos 3.5.2]开启模型合批

8.03 Day34---BaseMapper query statement usage
随机推荐
【云原生--Kubernetes】Pod资源管理与探针检测
sql server如何得到本条记录与上一条记录的差异,即变动值
Delphi-C端有趣的菜单操作界面设计
Dynamic programming of the division of numbers
[SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
C语言 -- 操作符详解
C专家编程 第5章 对链接的思考 5.1 函数库、链接和载入
MySQL数据库(基础)
npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
4.1 声明式事务之JdbcTemplate
力扣:96.不同的二叉搜索树
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
MySQL日志篇,MySQL日志之binlog日志,binlog日志详解
MySQL日期函数
力扣:63. 不同路径 II
[Cocos] cc.sys.browserType可能的属性
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
Gartner 权威预测未来4年网络安全的8大发展趋势
7.15 Day21---MySQL----索引