当前位置:网站首页>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);
}
边栏推荐
- MySQL date functions
- 去重的几种方式
- C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
- C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.1 Arrays are not pointers
- Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
- Performance testing with Loadrunner
- 获取单选框选中内容
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
- What are the functions of mall App development?
- 力扣:63. 不同路径 II
猜你喜欢

少年成就黑客,需要这些技能

高性能高可靠性高扩展性分布式防火墙架构

el-Select selector bottom fixed

The symbol table

Can 't connect to MySQL server on' localhost3306 '(10061) simple solutions

8、自定义映射resultMap

Delphi-C端有趣的菜单操作界面设计

canal实现mysql数据同步

npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND

触觉智能分享-SSD20X实现升级显示进度条
随机推荐
[SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
The idea setting recognizes the .sql file type and other file types
4.2 Declarative Transaction Concept
DataTable uses Linq for grouping and summarization, and converts the Linq result set into DataTable
JS basics - forced type conversion (error-prone, self-use)
px、em、rem的区别
[Evaluation model] Topsis method (pros and cons distance method)
Web Basics and Exercises for C1 Certification - My Study Notes
Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用
How to view sql execution plan offline collection
Write golang simple C2 remote control based on gRPC
4.2 声明式事务概念
MySQL日期函数
Turn: Management is the love of possibility, and managers must have the courage to break into the unknown
Cannot read properties of null (reading 'insertBefore')
8.03 Day34---BaseMapper查询语句用法
7.18 Day23----标记语言
2022年PMP考试延迟了,该喜该忧?
Cannot read properties of null (reading ‘insertBefore‘)
力扣:62.不同路径