For reading an image file, I have to use either of
Mat img = imread(file,CV_LOAD_IMAGE_COLOR);
or
Mat img = imread(file,CV_LOAD_IMAGE_GRAYSCALE);
This means I have to know in advance whether the file contains a color or mono image. Isn't there a way to know the number of channels in advance so that I can apply the image read according to the number of channels?