I want to detect which value is maximum from RGB. how can I detect that? I want to display which colour has highest occurrence with their RGB value. For example, In a image the RED colour has highest occurrence so it will display colour as RED and with their value in percentage.
I have tried it by getting rows and cols of image like below:
public Mat onCameraFrame(CvCameraViewFrame cvf) {
mRgba = cvf.rgba();
int rows = mRgba.rows();
int cols = mRgba.cols();
// int ch = mRgba.channels();
double R=0,G=0,B=0;
for (int i=0; i<rows; i++)
{
for (int j=0; j<cols; j++)
{
double[] data = mRgba.get(i, j); //Stores element in an array
R = data[0];
G= data[1];
B = data[2];
}
}
Imgproc.putText(mRgba,"R:"+R + "G:"+G +"B:"+B,new Point(10,52),Core.FONT_HERSHEY_COMPLEX,.7,new Scalar(5,255,255), 2,8,false );
return mRgba;
}
but it is taking to much time and screen is lagging because I have implemented code in onCameraFrame
. So how can I detect it fast in this method and which is the best way to it?
Thanks.