当前位置:网站首页>Opencv learning example code 3.2.4 LUT
Opencv learning example code 3.2.4 LUT
2022-07-02 03:52:00 【Terror blade】
#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <iomanip>
#include <opencv2/opencv.hpp>
#include <vector>
#include <opencv2/imgproc/types_c.h>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
uchar lutFirst[256];
for(int i=0;i<256;i++)
{
if(i<=100)
{
lutFirst[i]=0;
}
if(i>100&&i<=200)
{
lutFirst[i]=100;
}
if(i>200)
{
lutFirst[i]=255;
}
}
Mat lutOne(1,256,CV_8UC1,lutFirst);
uchar lutSecond[256];
for(int i=0;i<256;i++)
{
if(i<=100)
{
lutSecond[i]=0;
}
if(i>100&&i<=150)
{
lutSecond[i]=100;
}
if(i>150&&i<=200)
{
lutSecond[i]=150;
}
if(i>200)
{
lutSecond[i]=255;
}
}
Mat lutTwo(1,256,CV_8UC1,lutSecond);
uchar lutThird[256];
for(int i=0;i<256;i++)
{
if(i<100)
{
lutThird[i]=100;
}
if(i>100&&i<=200)
{
lutThird[i]=200;
}
if(i>200)
{
lutThird[i]=255;
}
}
Mat lutThree(1,256,CV_8UC1,lutThird);
vector<Mat> mergeMats;
mergeMats.push_back(lutOne);
mergeMats.push_back(lutTwo);
mergeMats.push_back(lutThree);
Mat LutTree;
merge(mergeMats,LutTree);
Mat img=imread("lena.png");
if(img.empty())
{
cout<<"open faile"<<endl;
return -1;
}
Mat gray,out0,out1,out2;
cvtColor(img,gray,COLOR_BGR2GRAY);
LUT(gray,lutOne,out0);
LUT(img,lutOne,out1);
LUT(img,LutTree,out2);
imshow("out0",out0);
imshow("out1",out1);
imshow("out2",out2);
waitKey(0);
return 0;
}
边栏推荐
猜你喜欢
蓝桥杯单片机省赛第十一届
Hands on deep learning (II) -- multi layer perceptron
NLog use
The second game of the 12th provincial single chip microcomputer competition of the Blue Bridge Cup
"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
Fourier series
蓝桥杯单片机省赛第十一届第二场
集成底座方案演示说明
Vite: configure IP access
How to do medium and long-term stocks, and what are the medium and long-term stock trading skills?
随机推荐
Sorted out an ECS summer money saving secret, this time @ old users come and take it away
[yolo3d]: real time detection of end-to-end 3D point cloud input
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
Kotlin basic learning 17
蓝桥杯单片机省赛第六届
[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
蓝桥杯单片机第六届温度记录器
Network connection mode of QT
[personnel density detection] matlab simulation of personnel density detection based on morphological processing and GRNN network
软件测试人的第一个实战项目:web端(视频教程+文档+用例库)
The first game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup
蓝桥杯单片机省赛第十一届第一场
The 8th Blue Bridge Cup single chip microcomputer provincial competition
【IBDFE】基于IBDFE的频域均衡matlab仿真
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
MySQL之账号管理
VS2010插件NuGet
"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
【小技巧】使用matlab GUI以对话框模式读取文件
JVM知识点