Reply by Mihai Cartoaje July 26, 20092009-07-26
> What do you mean with losless? > You can add values (beside the right scaling) to the color components > to fit in every window you decide. > You get every time losses in case of rounding errors.
It is lossless because the rounding errors are reversed at reconstruction. This is the reconstruction algorithm for the above color transform that is similar to JPEG YCbCr: B -= round(-0.171 * R) R -= round(-0.167 * B) B -= round(-0.171 * R) G -= round(Kb * B + Kr * R) B += G R += G
Reply by Mihai Cartoaje June 17, 20092009-06-17
I wrote,

> I posted a comparison between YIQ and YCbCr at,
I corrected an error and redid the comparison: http://groups.google.com/group/media-player/browse_thread/thread/4e0d4c83bba85be8
Reply by Jens Dierks May 30, 20092009-05-30
Mihai Cartoaje schrieb:
>> Y = 0.299 * R + 0.587 * G + 0.114 * B >> U = (B - Y) * 0.493 >> V = (R - Y) * 0.877 >> >> than YCbCr could be made this way, only by changing the factors >> for U and V to become Cb and Cr, with 5 multiplications? > > That is not lossless.
What do you mean with losless? You can add values (beside the right scaling) to the color components to fit in every window you decide. You get every time losses in case of rounding errors. Btw the inverse transform from YUV to RGB needs only 4 multiplications. But i dont wanted to degrade your code, because a general way to do a 3x3 matrix transform with only 5 multiplications sounds very good to me. Jens
Reply by Mihai Cartoaje May 30, 20092009-05-30
> Y = 0.299 * R + 0.587 * G + 0.114 * B > U = (B - Y) * 0.493 > V = (R - Y) * 0.877 > > than YCbCr could be made this way, only by changing the factors > for U and V to become Cb and Cr, with 5 multiplications?
That is not lossless.
Reply by Jens Dierks May 26, 20092009-05-26
Correction:
...
> because the G multiplier above is 1. > So in the end you need more multiplications?
Sorry, R and B are subtracted by a amount of G bevor, so G could be correct calculated!
Reply by Jens Dierks May 26, 20092009-05-26
Mihai Cartoaje wrote:
> It is possible to do any lossless linear color transform of the kind > YC1C2 using 5 multiplications
...
> For example, the JPEG YCbCr transform is, > > [0.299, 0.587, 0.114] > [0.5, -0.418688, -0.081312] > [-0.168736, -0.331264, 0.5]] > > To make the determinant 1, we can multiply the chroma channels by the > same multiple: > > [.299, .587, .114] > [1.029, -.861, -.167] > [-.347, -.681, 1.029] > > So the algorithm is, > > R -= G > B -= G > G += round(Kb * B + Kr * R) > B += round(-0.171 * R) > R += round(-0.167 * B) > B += round(-0.171 * R)
But in this case G is not: 0.299 * R + 0.587 *G + 0.114 * B because the G multiplier above is 1. So in the end you need more multiplications? And if you agree with me that YUV and YCbCr only differs in the scaling of the color components (UV versus CbCr), and YUV can be made like: Y = 0.299 * R + 0.587 * G + 0.114 * B U = (B - Y) * 0.493 V = (R - Y) * 0.877 than YCbCr could be made this way, only by changing the factors for U and V to become Cb and Cr, with 5 multiplications? Jens
Reply by Mihai Cartoaje May 25, 20092009-05-25
If theta is different from 45 degrees, there is a simpler algorithm:

R -= B
B -= G
G += round((Kb + Kr) * B + Kr * R)
B += round((0.5 - (1 - cos(45 - theta)) / sin(45 - theta)) * R)
R += round(sin(45 - theta) * B)
B -= round((((1 - cos(45 - theta)) / sin(45 - theta)) - sin(45 -
theta) * cos(45 - theta) / (4 - sin(45 - theta) * sin(45 - theta))) *
R)
Y = G
I = R
Q = B
Reply by Mihai Cartoaje May 19, 20092009-05-19
People can apply for a license by emailing me.

If I obtain a patent and a company uses it, it would allow me to write
useful software so the community wins.
Reply by Mihai Cartoaje May 19, 20092009-05-19
Prior art is 7 multiplications per pixel. Are there examples of prior
art using 5 multiplications per pixel?
Reply by Thomas Richter May 11, 20092009-05-11
Mihai Cartoaje wrote:
> It is possible to do any lossless linear color transform of the kind > YC1C2 using 5 multiplications.
And your point is...? A somewhat more useful observation would be: You could always implement it by lifting, thus making it lossless up to a scaling you can compensate for later on, for example. This is equally trivial. (-: So long, Thomas