title: Android: Image Noise Removal
body: <p>As stated in the documentation on improving the accuracy of OCR 
  <a href="https://code.google.com/p/tesseract-ocr/wiki/ImproveQuality#Noise" rel="nofollow noreferrer">https://code.google.com/p/tesseract-ocr/wiki/ImproveQuality#Noise</a>
  Noise reduction on a bitmap is very important so,</p>
  
  <p>I have this code that I referenced from here.</p>
  
  <p><a href="https://stackoverflow.com/questions/9480013/image-processing-to-improve-tesseract-ocr-accuracy">image processing to improve tesseract OCR accuracy</a></p>
  
  <p>And I have modified and debugged the code to look something like this:</p>
  
  <pre><code>public Bitmap RemoveNoise(Bitmap bmap)
  {
      for (int x = 0; x &lt; bmap.getWidth(); x++)
      {
          for (int y = 0; y &lt; bmap.getHeight(); y++)
          {
              int pixel = bmap.getPixel(x, y);
              if (pixel.R &lt; 162 &amp;&amp; pixel.G &lt; 162 &amp;&amp; pixel.B &lt; 162)
                  bmap.setPixel(x, y, Color.BLACK);
          }
      }
  
      for (int  x = 0; x &lt; bmap.getWidth(); x++)
      {
          for (int y = 0; y &lt; bmap.getHeight(); y++)
          {
              int pixel = bmap.getPixel(x, y);
              if (pixel.R &gt; 162 &amp;&amp; pixel.G &gt; 162 &amp;&amp; pixel.B &gt; 162)
                  bmap.setPixel(x, y, Color.WHITE);
          }
      }
  
      return bmap;
  }
  </code></pre>
  
  <p>My challenge is that after debugging the code I have error on pixel.R, pixel.G and pixel.B and that is where I am hooked up right now.
  Also, could this be a better algorithm or approach of removing noise from an image. Thanks</p>