opencv分离RGB三通道

这篇博客记录了作者在学习过程中关于OpenCV如何分离RGB三通道并修改图像颜色的经验,期间遇到了问题并进行了代码调整。
摘要由CSDN通过智能技术生成

注:本文非标准教程,仅是总结个人学习过程,可能存在纰漏,如有错误之处欢迎留言告知,非常感谢

本文用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"
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值