Color dectection using YCrCb instead of HUV

asked 2014-01-30 13:11:32 -0600

Al B gravatar image

I'm able to detect colors (i.e. green) using the code below:

Imgproc.cvtColor(rgbaImage, mHsvMat, Imgproc.COLOR_RGB2HSV_FULL); Core.inRange(mHsvMat, new Scalar(60, 100, 30), new Scalar(130, 255, 255), mProcessedMat); // Green color

However, I am not able to accomplish the same detection when I use "Imgproc.COLOR_RGB2YCrCb" instead of "Imgproc.COLOR_RGB2HSV_FULL" because I cannot figure out the values of the scalar min and max parameters for the YUV counterpart colors.

So, is it possible to detect colors using YCrCb using the inRange() method or do I need to use a different method? Or does anyone know how can I map the min and max parameters for YUV?

TIA!

edit retag flag offensive close merge delete

Comments

I failed to mention that I tried to convert the current values used in the Scalar parameters, but it didn't work.

Y = 0.299R + 0.587G + 0.114B; Cr = 128 + 0.5R - 0.4187G - 0.0813B; Cb = 128 - 0.1687R - 0.3313G + 0.5*B;

Al B gravatar imageAl B ( 2014-01-30 13:20:49 -0600 )edit