当前位置:网站首页>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 .
边栏推荐
- [exercise-2] (UVA 712) s-trees
- The concept of C language array
- Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
- Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
- HDU - 6024 building shops (girls' competition)
- Shell脚本编程
- PySide6 信号、槽
- Information security - threat detection - detailed design of NAT log access threat detection platform
- 快速转 TypeScript 指南
- Analysis of protobuf format of real-time barrage and historical barrage at station B
猜你喜欢
VS2019初步使用
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
D - Function(HDU - 6546)女生赛
【练习-5】(Uva 839)Not so Mobile(天平)
Penetration test (1) -- necessary tools, navigation
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
渗透测试 ( 1 ) --- 必备 工具、导航
Record of force deduction and question brushing
X-Forwarded-For详解、如何获取到客户端IP
D - function (HDU - 6546) girls' competition
随机推荐
JS call camera
[exercise -10] unread messages
0-1 knapsack problem (I)
China's peripheral catheter market trend report, technological innovation and market forecast
Opencv learning log 18 Canny operator
VS2019初步使用
【练习-10】 Unread Messages(未读消息)
CEP used by Flink
X-forwarded-for details, how to get the client IP
【练习-6】(Uva 725)Division(除法)== 暴力
Opencv learning log 12 binarization of Otsu method
[exercise-9] Zombie's Treasury test
Ball Dropping
基于web的照片数码冲印网站
Nodejs crawler
最全编程语言在线 API 文档
Research Report on shell heater industry - market status analysis and development prospect forecast
Basic Q & A of introductory C language
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
Truck History