问题
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