scoleman2272
scoleman2272

Reputation: 368

Converting a 4 channel matrix to 1 channel in Android using OpenCV

I've created a matrix from a ARGB_8888 bitmap like this:

Mat detectedFaceMat = Utils.bitmapToMat(bmp1);

The resultant matrix has 4 channels. I now need to compare it to 1 channel matrices. Not sure how to convert the 4 channel to 1 (I only need grayscale).

Upvotes: 0

Views: 2979

Answers (1)

Adi Shavit
Adi Shavit

Reputation: 17265

OpenCV supports CV_BGRA2GRAY with cv::cvtColor() or cvCvtColor() which converts BGRA pixels to Grey.
It is possible that ARGB is in fact BGRA in memory (this is the most common format). In this case The above conversion will work as expected.

If not, you can always use the green channel as a pretty good approximation for grey.

Upvotes: 2

Related Questions