-2

I am new in OpenCV code. I am working on a project and I need to split a video signal in its 3 different components. I have already obtain the RGB matrix of the video signal such us mat object. However, I need to convert this mrgba mat into a int to make this equation:

ExG = 2*g - r - b; Exceso de Verdes Woobeke 1995

Another possibility could be to operate directly with three matrixes R, G and B, after dividing the main one(mrgba), but I do not know the size of these matrixes and I neither know how to make this equation with them.

Any ideas of how to solve this problem?

This is the part of my code:

@Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

        mrgba = inputFrame.rgba();



        Mat r =new Mat();
        Core.extractChannel(mrgba, r, 0);
        Mat g =new Mat();
        Core.extractChannel(mrgba, g, 1);
        Mat b =new Mat();
        Core.extractChannel(mrgba, b, 2);


        return mrgba;
    }

I have right now 3 different matrixes, one per channel "r", "g" and "b".

MD. Nazmul Kibria
  • 1,080
  • 10
  • 21

1 Answers1

0

Opencv supports Matrix expression. Here is the code:

@Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

        mrgba = inputFrame.rgba();
        Mat r =new Mat();
        Core.extractChannel(mrgba, r, 0);
        Mat g =new Mat();
        Core.extractChannel(mrgba, g, 1);
        Mat b =new Mat();
        Core.extractChannel(mrgba, b, 2);

        Mat result = 2 * g - r - b;
        return result;
    }
MD. Nazmul Kibria
  • 1,080
  • 10
  • 21