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.