2015-06-20 12:25:38 -0500 received badge ● Scholar (source) 2015-06-15 04:27:26 -0500 received badge ● Supporter (source) 2015-06-15 04:27:18 -0500 commented answer How could I extract layers for differet color systems? Thank you for your help. Using the split function gives me grayscale layers for all XYZ, YCrCb and HSV color systems. Is that true? 2015-06-15 03:44:45 -0500 asked a question How could I extract layers for differet color systems? Hi I am new to opencv. I wrote a program to extract RGB layers from an 3channels jpg image. Then I used cvtColor to convert RGB image ro other color systems (CIE XYZ, YCrCb, HSV, HLS, ...). But when I used same algorithm (as RGB layer extraction) the result was wrong. for XYZ layers, I got something near RGB layers. for YCrCb I got 3 color layers (R, G, B). What is wrong with my code? How can I extract YCrCb, HSV, HLS and Lab* layers? Here is my sample code for XYZ layers cvtColor(orig_image, image, CV_RGB2XYZ); Mat xlayer, ylayer, zlayer; xlayer = image.clone(); ylayer = image.clone(); zlayer = image.clone(); unsigned int channels = image.channels(); unsigned int rows = image.rows; unsigned int cols = image.cols * channels; unsigned char *xrow, *yrow, *zrow; if(image.isContinuous()) { cols *= rows; rows = 1; } for(unsigned int i=0; i(i); yrow = ylayer.ptr(i); zrow = zlayer.ptr(i); for(unsigned int j = 0; j < cols; j+=3) { xrow[j] = xrow[j+1] = 0; yrow[j] = yrow[j+2] = 0; zrow[j+1] = zrow[j+2] = 0; } } namedWindow("X Layer Window", WINDOW_AUTOSIZE); namedWindow("Y Layer Window", WINDOW_AUTOSIZE); namedWindow("Z Layer Window", WINDOW_AUTOSIZE); imshow("X Layer Window", xlayer); imshow("Y Layer Window", ylayer); imshow("Z Layer Window", zlayer);