当前位置:网站首页>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 .
边栏推荐
- 0-1背包問題(一)
- Find 3-friendly Integers
- China potato slicer market trend report, technical dynamic innovation and market forecast
- Understand what is a programming language in a popular way
- Penetration test (8) -- official document of burp Suite Pro
- Gartner: five suggestions on best practices for zero trust network access
- Penetration test (4) -- detailed explanation of meterpreter command
- 区间和------离散化
- JS call camera
- Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
猜你喜欢
Penetration test (4) -- detailed explanation of meterpreter command
Gartner:关于零信任网络访问最佳实践的五个建议
The concept of C language array
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
7-1 understand everything (20 points)
Record of force deduction and question brushing
C语言数组的概念
Penetration test (1) -- necessary tools, navigation
Optimization method of path problem before dynamic planning
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
随机推荐
Opencv learning log 18 Canny operator
Alice and Bob (2021牛客暑期多校训练营1)
Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
【练习-2】(Uva 712) S-Trees (S树)
Pyside6 signal, slot
基于web的照片数码冲印网站
The concept of C language array
【练习-10】 Unread Messages(未读消息)
Data storage in memory & loading into memory to make the program run
Ball Dropping
Essai de pénétration (1) - - outils nécessaires, navigation
Information security - threat detection engine - common rule engine base performance comparison
Opencv learning log 13 corrosion, expansion, opening and closing operations
The most complete programming language online API document
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
b站 實時彈幕和曆史彈幕 Protobuf 格式解析
[exercise-7] (UVA 10976) fractions again?! (fraction split)
信息安全-史诗级漏洞Log4j的漏洞机理和防范措施