Separate hsv channels in opencv

醉酒当歌 提交于 2019-12-18 09:41:32

问题


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.

The code used:

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

回答1:


You can simply use split:

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

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



来源:https://stackoverflow.com/questions/21014626/separate-hsv-channels-in-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!