12

Whats the real conversion formula for this because I found so many ways on how to convert I don't know which one is real

From wikipedia: enter image description here

From microsoft https://msdn.microsoft.com/en-us/library/ff635643.aspx enter image description here:

and microsoft is the same with this conversion site http://www.equasys.de/colorconversion.html:

enter image description here

Can anybody explain the difference of the formula?

Red Viper
  • 477
  • 1
  • 5
  • 22
  • 5
    The first one is for converting *analog* to digital, allowing "footrom" and "headroom" (explained on Wikipedia). The latter ones are the JPEG conversion, allowing usage of the full 8 bit range (0...255), also explained in the Wikipedia article, a little further down. So... It depends on what your input is. – Harald K Feb 24 '16 at 14:04
  • I dont understand the explanation on wikipedia about the first one, so If my input is JPEG I will use the second conversion to get the YCbCr? – Red Viper Feb 24 '16 at 14:43
  • If your input is JPEG, then the data is most likely already in YCbCr (the JPEG variant). So I'm not sure what you want to achieve by that... But if your input is digital data, then using the second version makes the most sense, yes, as you should be able to convert back and forth lossless. – Harald K Feb 25 '16 at 08:09
  • Check out IPP documentation: https://software.intel.com/en-us/node/503873 – Rotem Jun 23 '16 at 18:04
  • Here is a wayback machine link to the second link in the question which seems to no longer be valid: https://web.archive.org/web/20180421030430/http://www.equasys.de/colorconversion.html – Gregor Hartl Watters Sep 16 '22 at 15:22
  • @HaraldK This is a generic question about an image colour space conversion formula. So is the suggested duplicate question, but it concerns a specific language and framework. So, this is not a duplicate of that question. – Andreas is moving to Codidact Mar 27 '23 at 19:44

1 Answers1

3

If it still actual they are almost the same. Differences are what value ranges you'll get in the result.

From Wiki's matrix (R',G',B' = 0..1) values will be: Y = 0..219, Cb = -112..112, Cr = -112..112. You can bring it to other matrices with dividing Y formula by 219, and Cb, Cr fomulas by 224.

From Microsoft's one (R,G,B = 0..255) you'll get Y = 0..255, Cb ≈ -127.5 .. 127.5, Cr ≈ -127.5 .. 127.5

The third matrix solves problems with negative numbers by adding 128 to them. The difference from Microsoft's matrix lies in the matrices multiplication.