Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The output of convertTo will have the same channels count as input. It seem like CurrentMat has CV_32FC4 type, so Result will have CV_8UC4 (CV_8UC4 == 24). If you want to convert your image from 4-channel to 3-channel you should use cvtColor with CV_BGRA2BGR:

Mat Temp;
CurrentMat.convertTo(Temp, CV_8U);
Mat Result;
cvtColor(Temp, Result, CV_BGRA2BGR);

The output of convertTo will have the same channels count as input. It seem like CurrentMat has CV_32FC4 type, so Result will have CV_8UC4 (CV_8UC4 == 24). If you want to convert your image from 4-channel to 3-channel you should use cvtColor with CV_BGRA2BGR: (or CV_BGRA2GRAY for single channel output):

Mat Temp;
CurrentMat.convertTo(Temp, CV_8U);
Mat Result;
cvtColor(Temp, Result, CV_BGRA2BGR);