Color determination using YCrCb color space?

This code I found trying to track red in the RGB color space,

  // red color detection, turn the detected one into white
  if (((red > (0.85 * (green + blue))) && (red > 105)) 
     && ((red - green > 73)) && (((green < 150) 
     || ((green >= 150) && (blue > 140)))))  {
        // set the pixel to white
        red = 255; green = 255; blue = 255;
  }

Does anyone know how to track color using YCrCb color space instead of RGB? I just don’t know which range for each color to track it, for example. red color in YCrCb.

Edit : I tried HSV, it does not give a better result than RGB is higher than therefore, I think use YCrCb.

Thank.

+1
source share
3 answers

. (YCrCb) , mpeg. , 4: 2: 2, , Y ( ) RGB, Yb ( ) Yr ( ) . .

, , , HSV ( HSI). H (Hue) , 0..359 (360 ). , 0..255, 16- . S ( H ), S ( I) .

:

I = 1/3 * (R + G + B)

S = 1 - (3/(R + G + B)) * (min (R, G, B))

(R-G) + (R-B) * (G-B))))
+1

HSV, , , .

0

In YCbCr, a typical range is from 16 to 240 for each component. See the Next Wikipedia Entry for various formulas for converting between RGB and YCbCr.

0
source

Source: https://habr.com/ru/post/1785630/


All Articles