title: convert a RGB image to grayscale Image reducing the memory in java
body: <p>I have an RGB bufferedImage bImg .<br/>
  I want to convert bImg to gray image.   </p>
  
  <pre><code>BufferedImage grayIm=new BufferedImage(bImg.getWidth(null), bImg.getHeight(null), BufferedImage.TYPE_BYTE_GRAY); 
  </code></pre>
  
  <p>I have tried this grayIm but i can not set the grayscale values for this grayIm.</p>