title: Proper image thresholding to prepare it for OCR in python using opencv
body: <p>I am really new to opencv and a beginner to python.</p>
  
  <p>I have this image:</p>
  
  <p><a href="https://i.stack.imgur.com/ycDcm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ycDcm.png" alt="original bmp 24bit image"></a></p>
  
  <p>I want to somehow apply proper thresholding to keep nothing but the 6 digits.</p>
  
  <p>The bigger picture is that I intend to try to perform manual OCR to the image for each digit separately, using the k-nearest neighbours algorithm on a per digit level (kNearest.findNearest)</p>
  
  <p>The problem is that I cannot clean up the digits sufficiently, especially the '7' digit which has this blue-ish watermark passing through it.</p>
  
  <p>The steps I have tried so far are the following:</p>
  
  <p>I am reading the image from disk</p>
  
  <pre><code># IMREAD_UNCHANGED is -1
  image = cv2.imread(sys.argv[1], cv2.IMREAD_UNCHANGED)
  </code></pre>
  
  <p>Then I'm keeping only the blue channel to get rid of the blue watermark around digit '7', effectively converting it to a single channel image</p>
  
  <pre><code>image = image[:,:,0] 
  # openned with -1 which means as is, 
  # so the blue channel is the first in BGR
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tc6wL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tc6wL.png" alt="single channel - red only - image"></a></p>
  
  <p>Then I'm multiplying it a bit to increase contrast between the digits and the background:</p>
  
  <pre><code>image = cv2.multiply(image, 1.5)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wLGw4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wLGw4.png" alt="multiplied image to increase contrast"></a></p>
  
  <p>Finally I perform Binary+Otsu thresholding:</p>
  
  <pre><code>_,thressed1 = cv2.threshold(image,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hTsi1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hTsi1.png" alt="binary Oahu thresholded image"></a></p>
  
  <p>As you can see the end result is pretty good except for the digit '7' which has kept a lot of noise.</p>
  
  <p>How to improve the end result? Please supply the image example result where possible, it is better to understand than just code snippets alone.</p>