当前位置:网站首页>Opencv learning log 29 -- gamma correction
Opencv learning log 29 -- gamma correction
2022-07-06 16:07:00 【@Spring sauce】
Preface
This article focuses on opencv Image processing gamma Application of correction .
One 、gamma correction
// The first question is gamma correction
#include <opencv2/opencv.hpp>
#include <iostream>
#include<cmath>
using namespace cv;
using namespace std;
int main()
{
cv::Mat dst;
cv::Mat dstbin;
cv::Mat dsttemp;
cv::Mat finalpicture;
cv::Mat src = imread("C://Users//john//Desktop//1.jpg");
cv::Mat srcgray = imread("C://Users//john//Desktop//1.jpg", 0);
int i, j;
//cout << sizeof(srcgray) << endl; 538 478
int row = srcgray.rows;
int col = srcgray.cols;
cout << row << endl;
cout << col << endl;
int size = row*col;
// double sum = 0;
// cout << 1 / 0.5 << endl;
float lut[256];// Definition table
float r =0.4;
for (i = 0; i <= 255; i++)
{
lut[i] =float( i )/float(255);
}
float secondlut[256];
for (i = 0; i <= 255; i++)
{
secondlut[i] = pow(lut[i], r);
}
for (int j = 0; j < row; j++) // Read total gray value
{
for (int i = 0; i < col; i++)
{
uchar average = srcgray.at<uchar>(j, i);
srcgray.at<uchar>(j, i) = secondlut[average]*255;
}
}
//(x/sum)~r*255
cout << sum << endl;
cv::imshow("srcgray", srcgray);
cv::imshow("final", src);
waitKey(0);
}
summary
1. The code can run directly , If you don't understand, you can leave a message .
2. Missing material pictures , Follow up, thank you .
边栏推荐
- C语言数组的概念
- 想应聘程序员,您的简历就该这样写【精华总结】
- Flink 使用之 CEP
- Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
- D - function (HDU - 6546) girls' competition
- 0-1背包問題(一)
- Optimization method of path problem before dynamic planning
- Vs2019 initial use
- Research Report on market supply and demand and strategy of China's earth drilling industry
- Opencv learning log 13 corrosion, expansion, opening and closing operations
猜你喜欢
Data storage in memory & loading into memory to make the program run
渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
Borg maze (bfs+ minimum spanning tree) (problem solving report)
[exercise-4] (UVA 11988) broken keyboard = = (linked list)
Basic Q & A of introductory C language
Vs2019 initial use
PySide6 信号、槽
差分(一维,二维,三维) 蓝桥杯三体攻击
Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
Gartner: five suggestions on best practices for zero trust network access
随机推荐
洛谷P1102 A-B数对(二分,map,双指针)
[exercise-5] (UVA 839) not so mobile (balance)
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
【高老师UML软件建模基础】20级云班课习题答案合集
D - Function(HDU - 6546)女生赛
Opencv learning log 13 corrosion, expansion, opening and closing operations
Borg Maze (BFS+最小生成树)(解题报告)
Find 3-friendly Integers
最全编程语言在线 API 文档
C 基本语法
Research Report of cylindrical grinder industry - market status analysis and development prospect forecast
信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
China's earthwork tire market trend report, technical dynamic innovation and market forecast
Record of force deduction and question brushing
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
Opencv learning log 16 paperclip count
【练习-9】Zombie’s Treasure Chest
Opencv learning log 18 Canny operator
VS2019初步使用