2014年8月2日 星期六

[OpenCV] Mat.convertTo() method not working ? (8UC3 to 8UC1, etc)

** Note : issues mentioned in this article is based on OpenCV4Android (OpenCV in Java)
** might not suit all version of OPCV.

When you want to convert a 3-channel Mat to single channel, 
should use


Imgproc.cvtColor(Mat src, Mat dst, int code) ;

instead of 


Mat.convertTo(Mat m, int rtype);

Because the result of Mat.convertTo() will have the same CvType of input mat.

Example:
when trying to convert to single channel, using :

Imgproc.cvtColor(_inputMat, resultMat, Imgproc.COLOR_RGBA2GRAY);

沒有留言:

張貼留言