title: Convert 8bit Color image to Gray For VGA
body: <p>I have a <a href="https://en.wikipedia.org/wiki/8-bit_color" rel="nofollow">8 bit color image</a> . What is the method to convert this into a <a href="https://en.wikipedia.org/wiki/Grayscale" rel="nofollow">Grayscale Image</a> .</p>
  
  <p>For a normal 24 bit true color RGB image, we either perform  averaging ( R + G + B ) / 3 </p>
  
  <p>And then there's' the <a href="https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale" rel="nofollow">Weighted Averaging</a> wherein we calculate  0.21 R + 0.72 G + 0.07 B.</p>
  
  <p>However these above formula works for a 24 bit image (correct me if i'm wrong) . Where 8 bits are used to denote R, G, B content each. Thus when we apply the above averaging methods, we get a resultant 8 bit grayscale image from a 24 bit True color image.</p>
  
  <p>So how to calculate grayscale image for an 8 bit color image : </p>
  
  <p>Please note : 
  Structure of an 8 bit color image is as follows : 
  <a href="https://en.wikipedia.org/wiki/8-bit_color" rel="nofollow">Refer this link </a> </p>
  
  <pre><code>Bit    7  6  5  4  3  2  1  0
  Data   R  R  R  G  G  G  B  B
  </code></pre>
  
  <p>As we can see,</p>
  
  <ul>
  <li>Bits 7,6,5 denote Red content</li>
  <li>Bits 4,3,2 denote Green content</li>
  <li>Bits 1,0 denote Blue content</li>
  </ul>
  
  <p>So the above image will actually have 4 shades in total
  (because, in grayscale, a white pixel is obtained when there is 100 % contribution of each of the R,G,B components. And since Blue component has only 2 bits, effectively, there are 2<sup>2</sup> combinations i.e. 4 levels. )</p>
  
  <p>Therefore, if i consider 2 bits of R ,G and B, i manage to obtain gray levels as follows :</p>
  
  <pre><code>R   G   B   GrayLevel
  00  00  00   Black
  01  01  01   Gray 1
  10  10  10   Gray 2
  11  11  11   White 
  </code></pre>
  
  <p>Which bits to consider from Red and Green components and which to ignore .! </p>
  
  <p>How to quantify the graylevels for values of bits other than the ones mentioned above. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I want to implement the above system upon an FPGA, hence memory is a keen aspect. Quality of the image doesn't matter much. Somehow is it possible to quantify all the values of the 8 bit color img into the respective gray shades ?</p>