注:本文非标准教程,仅是总结个人学习过程,可能存在纰漏,如有错误之处欢迎留言告知,非常感谢
本文用RGB通道来改变图像颜色。
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
using namespace std;
using namespace cv;
int R = 10, G = 10, B = 10;
static Mat frame;
//1//
//1//
//2//
vector<Mat> channels;
Mat channels1, channels2, channels3;
Mat img_color_channel;
vector<Mat> newChannels;
//2//
static void callbackAdjust(int, void *);
int main()
{
frame = imread("1.jpg");
//2//
split(frame, channels);
channels1 = channels[0];//获取通道1
channels2 = channels[1];//获取通道2
channels3 = channels[2];//获取通道3
//2//
namedWindow("test");
createTrackbar("R", "test", &R, 255, callbackAdjust);
createTrackbar("G", "test", &G, 255, callbackAdjust);
createTrackbar("B", "test", &B, 255, callbackAdjust);
/*for (;;)
{*/
//cap >> frame;
imshow("src"