本文介绍了OpenCV中的独立HSV通道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在opencv中有一个hsv ma​​t文件,我想分隔通道.我发现cvSplit(hsv,h,s,v,NULL),但是不适用于Mat文件.那么,如何只保留Mat图像文件中的第一个通道h呢?我的结果是上面的.基本上就是我转换的图像,我可以看到脸,但是色调很奇怪.

I am having an hsv mat file in opencv and I want to separate the channels. I found cvSplit( hsv, h, s, v, NULL ), but it doesn't work with Mat files. How is it then, to keep just the first channel h of from the Mat image file??My result is the above. Basically is the image that I convert, I can see the face but in weird tones.

使用的代码:

    cvtColor(cropped_rgb, cropped_hsv, CV_BGR2HSV);
    split(cropped_hsv, channels);
    cropped_hsv = channels[0];
    imshow("cropped_hsv", cropped_hsv);

推荐答案

您可以简单地使用 split :

Mat hsv;
vector<Mat> channels;
split(hsv, channels);

channels [0],channels [1],channels [2]将分别包含您的H,S,V.

channels[0], channels[1], channels[2] will contain your H, S, V respectively.

这篇关于OpenCV中的独立HSV通道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 18:05