Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if you load it with :

imread({myFile}, CV_LOAD_IMAGE_COLOR)

you'll force it to return a 3 channel rgb (CV_8UC3) Mat, if it had alpha, it gets discarded already, if it was grey - you get a 3chanel grayscale img.

imread({myFile}, CV_LOAD_IMAGE_UNCHANGED)

will return either a 1, 3, or 4 channel img, depending on the file. so you will have to check it:

if ( img.channels() = 3 ) 
// process rgb...