MIT_MatlabToolbox/trunk/utils/VisionPrePostProcessor/main_offboard_image.c
//rgb to yuv conversion of image
rgb to yuv conversion of image
rgb to yuv conversion of image
void RGB_to_YUV
     (float  **R,          
      float  **G,          
      float  **B,          
      float  **Y,          
      float  **U,         
      float  **V,         
      long    nx,          
      long    ny)          
{
long    i, j;        
for (j=0;j<ny;j++)
  for (i=0;i<nx;i++)
  {
	      Y[i][j] =        (0.1277   * R[i][j]
	                   +   0.5212   * G[i][j]
	                   +   0.21   * B[i][j]) + 16.0;
	      U[i][j] =   ((-0.0737 * R[i][j] - 0.3007 * G[i][j] + 0.3744 * B[i][j])) + 128.0;
	      V[i][j] =   (( 0.5334 * R[i][j] - 0.3802 * G[i][j] - 0.1532 * B[i][j])) + 128.0;
  }
 return;
}
void RGB_to_YUV ( float * * R , float * * G , float * * B , float * * Y , float * * U , float * * V , long nx , long ny ) { long i , j ; for ( j = 0 ; j < ny ; j ++ ) for ( i = 0 ; i < nx ; i ++ ) { Y [ i ] [ j ] = ( 0.1277 * R [ i ] [ j ] + 0.5212 * G [ i ] [ j ] + 0.21 * B [ i ] [ j ] ) + 16.0 ; U [ i ] [ j ] = ( ( -0.0737 * R [ i ] [ j ] - 0.3007 * G [ i ] [ j ] + 0.3744 * B [ i ] [ j ] ) ) + 128.0 ; V [ i ] [ j ] = ( ( 0.5334 * R [ i ] [ j ] - 0.3802 * G [ i ] [ j ] - 0.1532 * B [ i ] [ j ] ) ) + 128.0 ; } return ; }
rgb to yuv conversion of image
rgb to yuv conversion of image
/* Red channel of RGB image */ /* Green channel of RGB image */ /* Blue channel of RGB image */ /* Y channel of YCbCr image */ /* Cb channel of YCbCr image */ /* Cr channel of YCbCr image */ /* pixel number in x-direction */ /* pixel number in y-direction */ /* loop variables */