title: Converting RGB to Luv
body: <p>i'm trying to convert an rgb image to L<em>u</em>v, i have some problem. The L component is good, but when i show the u and v component both are black(all pixels have value 0).</p>
  
  <pre><code>        for (int i = 0; i&lt;height; i++)
              for (int j = 0; j&lt;width; j++)
              {
                  Vec3b v3 = src.at&lt;Vec3b&gt;(i, j);
                  float b = ((float)v3[0]) / 255;
                  float g = ((float)v3[1]) / 255;
                  float r = ((float)v3[2]) / 255;
  
                  float x = r * 0.412453 + g * 0.357580 + b * 0.180423;
                  float y = r * 0.212671 + g * 0.715160 + b * 0.072169;
                  float z = r * 0.019334 + g * 0.119193 + b * 0.950227;
  
                  //L
                  if (y &gt; 0.008856) {
                      l_mat.at&lt;uchar&gt;(i, j) = 255 / 100 * (116 * pow(y, 1.0 / 3.0));
                      dst.at&lt;Vec3b&gt;(i, j)[0] = 255 / 100 * (116 * pow(y, 1.0 / 3.0));
                  //  printf("%d / " , l_mat.at&lt;uchar&gt;(i, j));
                  }
                  else { 
                      l_mat.at&lt;uchar&gt;(i, j) = 255 / 100 * (903.3 * y); 
                      dst.at&lt;Vec3b&gt;(i, j)[0] = 255 / 100 * (903.3 * y);
                  }
  
                  float u = 4 * x / (x + 15 * y + 3 * z);
                  float v = 9 * y / (x + 15 * y + 3 * z);
                  //printf("u: %.2f , v:%.2f || ", u, v);
  
                  //U
                  u_mat.at&lt;uchar&gt;(i, j) = 255 / 354 * (13 * l_mat.at&lt;uchar&gt;(i, j)*(u - 0.19793943) + 134);
                  //printf("%d / ", u_mat.at&lt;uchar&gt;(i, j));
                  dst.at&lt;Vec3b&gt;(i, j) = 255 / 354 * (13 * l_mat.at&lt;uchar&gt;(i, j)*(u - 0.19793943) + 134);
  
                  //v
                  v_mat.at&lt;uchar&gt;(i, j) = 255 / 262 * (13 * l_mat.at&lt;uchar&gt;(i, j)*(v - 0.46831096)+140);
                  dst.at&lt;Vec3b&gt;(i, j) = 255 / 262 * (13 * l_mat.at&lt;uchar&gt;(i, j)*(v - 0.46831096) + 140);
              }
  </code></pre>
  
  <p>I have to do the conversions pixel by pixel, i can't use cvtcolor.</p>