1

When I do implement RGB2YCBCR on verilog. I saw several ways to convert RGB to YCBCR. Some of it are very simple. But others are quite complex.

For example, if we use

y = (r >> 2) + (g >> 1) + (b >> 2);

it is very easy to implement to hardware

But some people say that

y = (r*4899 + g*9617+ b*1868+ 8192) >> 14 

is faster???

I don't know why they have this equation and why a complex equation better than a simple equation. And WHY THEY USE IT instead of that simple equation.

P/S: I saw that OpenCV also uses that complex one. Thank a lot!

dave_59
  • 39,096
  • 3
  • 24
  • 63

1 Answers1

1

On processors with a multiplier and a barrel shifter, all these operations take a single clock cycle and the second formula cannot be faster (5 ops vs. 7).

The complex equation is mandated by a standard coming from the television technology, with historical and technological reasons (https://en.wikipedia.org/wiki/Rec._601).

Color spaces is a rather complex topic.


Note that the first formula is not normalized: if the input values are in range [0,1], the outputs are in [0, 10], and you should divide by 10. This would make the first formula much slower.