u24c02
Advanced Member level 1
- Joined
- May 8, 2012
- Messages
- 404
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,298
- Activity points
- 4,101
Hi..
I trying to converse from RGB to YUV again RGB like as the following.
for (i=0; i<640*480; i++)
{
Y = (char)((float)0.213*R+(float)0.715*G+(float)0.072*B);
CB = (char)((float)-0.117*R-(float)0.394*G+(float)0.511*B)+128;
CR = (char)((float)0.511*R-(float)0.464*G-(float)0.047*B)+128;
}
////////////////////////////////////////////////////////////////
for (i=0; i<640*480; i++)
{
R = (char)((float)Y+(float)1.540*(CR-128));
G = (char)((float)Y-(float)0.459*(CR-128)-0.183*(CB-128));
B = (char)((float)Y+(float)1.816*(CB-128));
}
When i have conversed, some pixels are strange exchanged.
Q1. How much each have range above Y, CB, CR.?
Q2. Above transform code is right?
I trying to converse from RGB to YUV again RGB like as the following.
for (i=0; i<640*480; i++)
{
Y = (char)((float)0.213*R+(float)0.715*G+(float)0.072*B);
CB = (char)((float)-0.117*R-(float)0.394*G+(float)0.511*B)+128;
CR = (char)((float)0.511*R-(float)0.464*G-(float)0.047*B)+128;
}
////////////////////////////////////////////////////////////////
for (i=0; i<640*480; i++)
{
R = (char)((float)Y+(float)1.540*(CR-128));
G = (char)((float)Y-(float)0.459*(CR-128)-0.183*(CB-128));
B = (char)((float)Y+(float)1.816*(CB-128));
}
When i have conversed, some pixels are strange exchanged.
Q1. How much each have range above Y, CB, CR.?
Q2. Above transform code is right?