To be absolute sure that the channel number X
corresponds to the channel you are after, consult the channelSeq
attribute of the IPL Image structure. If channelSeq[X]
gives the name (a character) of the channel you are after, then you found it.
But, given how this attribute is documented (along other interesting ones), even if you were always using IPLImage
, there is no guarantee that the information contained there would be accurate. Thus, to be absolutely sure about the channel sequence in your image you have to trust the conversion specification and remember that yourself. So, if you start with an image in BGR
and convert using BGR2YUV
, then you trust that the Y
channel is the first one, and so on. If OpenCV ever changes BGR2YUV
to mean that Y
goes to the last channel, and so on, then too bad for you.