php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 433|回复: 0

OpenCV将图像分离为rgb,hls,hsv通道并显示

[复制链接]

2615

主题

2622

帖子

9281

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
6544
贡献
0
注册时间
2021-4-14
最后登录
2024-4-19
在线时间
665 小时
QQ
发表于 2022-7-29 10:54:14 | 显示全部楼层 |阅读模式
#include<opencv2/opencv.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<iostream>

using namespace std;
using namespace cv;
int main()
{
    Mat img;
       img = imread("11.png");

    if (img.empty())
    {
        cout << "could not load image!" << endl;
    }
    Mat img_bgr,img_hsv, img_hls;
    cvtColor(img, img_hsv, COLOR_BGR2HSV);
    cvtColor(img, img_hls, COLOR_BGR2HLS);
    img_bgr = img.clone();
    vector<Mat> hsvSplit;
    vector<Mat> hlsSplit;
    vector<Mat> bgrSplit;
    split(img_hsv, hsvSplit);
    split(img_hls, hlsSplit);
    split(img_bgr, bgrSplit);
    Mat hsv_h = hsvSplit[0];
    Mat hsv_s = hsvSplit[1];
    Mat hsv_v = hsvSplit[2];
    Mat hls_h = hlsSplit[0];
    Mat hls_l = hlsSplit[1];
    Mat hls_s = hlsSplit[2];
    Mat bgr_b = bgrSplit[0];
    Mat bgr_g = bgrSplit[1];
    Mat bgr_r = bgrSplit[2];
    imshow("hsv_h", hsv_h);
    imshow("hsv_s", hsv_s);
    imshow("hsv_v", hsv_v);
    imshow("hls_h", hls_h);
    imshow("hls_l", hls_l);
    imshow("hls_s", hls_s);
    imshow("bgr_b", bgr_b);
    imshow("bgr_g", bgr_g);
    imshow("bgr_r", bgr_r);
    waitKey(0);
      return 1;

}





上一篇:图的宽度_深度优先遍历(链表)
下一篇:opencv车辆检测系统
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )51LA统计

GMT+8, 2024-4-19 22:13 , Processed in 0.177601 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表