View Full Version : Convert YUV to RGB
raja75
29th March 2006, 06:29
Hello,
I am new to this group. I want to convert YUV format to RGB format and vice versa.... in C++. Any specific link or suggestion would be useful...
thanks in advance...
Raja
Bester
29th March 2006, 09:41
Maybe this helps...
/*================================== RGB-YUV =================================*/
void rgb_to_yuv(float r[8][8],float g[8][8],float b[8][8],float y[8][8],float u[8][8],float v[8][8])
{
int i,j;
for ( i=0 ; i<8 ; i++ ){
for ( j=0 ; j<8 ; j++ ){
y[i][j]= 0.299 *r[i][j]+0.587 *g[i][j]+0.114 *b[i][j] ;
u[i][j]=-0.1687*r[i][j]-0.3313*g[i][j]+0.5 *b[i][j]+128;
v[i][j]= 0.5 *r[i][j]-0.4187*g[i][j]-0.0813*b[i][j]+128;
}
}
}
/*================================== YUV-RGB =================================*/
void yuv_to_rgb(float y[8][8],float u[8][8],float v[8][8],float r[8][8],float g[8][8],float b[8][8])
{
int i,j;
for ( i=0 ; i<8 ; i++ ){
for ( j=0 ; j<8 ; j++ ){
r[i][j]=y[i][j] +1.402 *(v[i][j]-128);
g[i][j]=y[i][j]-0.34414*(u[i][j]-128)-0.71414*(v[i][j]-128);
b[i][j]=y[i][j]+1.772 *(u[i][j]-128) ;
}
}
}
psood21
30th April 2007, 17:04
hie friend i saw the code which u posted for yuv to rgb conversion...... i have an assignment at hand in which i hve to do this conversion using a c++ program....i was wondering if u could kindly help me wid my assignment....it would be gr8 help coz i m in a gr8 trouble.....waiting for reply thanks
-nav
Guest
30th April 2007, 17:38
Asking other people to do your homework is frowned upon. You won't become a competent developer unless you learn to do things yourself.
psood21
30th April 2007, 22:03
sir,
first of all this is not my school assignment....secondly this is something i am doing for my friday evening project at my job.... i am in no means a developer....i am fm electrical field.....it is just that i m trying my hands at something new....i hve built a code which i think is not wht i wanted......so looking at the code above i was thinking if i could share code wid him it will help me a lot....thanks
-nav
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.