title: Remove background noise from image to make text more clear for OCR
body: <p>I've written an application that segments an image based on the text regions within it, and extracts those regions as I see fit. What I'm attempting to do is clean the image so OCR (Tesseract) gives an accurate result. I have the following image as an example:</p>
  
  <p><a href="https://i.stack.imgur.com/eyYWk.png"><img src="https://i.stack.imgur.com/eyYWk.png" alt="enter image description here"></a></p>
  
  <p>Running this through tesseract gives a widely inaccurate result. However cleaning up the image (using photoshop) to get the image as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/4Rvis.png"><img src="https://i.stack.imgur.com/4Rvis.png" alt="enter image description here"></a></p>
  
  <p>Gives exactly the result I would expect. The first image is already being run through the following method to clean it to that point:</p>
  
  <pre><code> public Mat cleanImage (Mat srcImage) {
      Core.normalize(srcImage, srcImage, 0, 255, Core.NORM_MINMAX);
      Imgproc.threshold(srcImage, srcImage, 0, 255, Imgproc.THRESH_OTSU);
      Imgproc.erode(srcImage, srcImage, new Mat());
      Imgproc.dilate(srcImage, srcImage, new Mat(), new Point(0, 0), 9);
      return srcImage;
  }
  </code></pre>
  
  <p>What more can I do to clean the first image so it resembles the second image?</p>
  
  <p>Edit: This is the original image before it's run through the <code>cleanImage</code> function.</p>
  
  <p><a href="https://i.stack.imgur.com/aRh8C.png"><img src="https://i.stack.imgur.com/aRh8C.png" alt="enter image description here"></a></p>