title: How can I blue-box an image?
body: <p>I have a scanned image which is basically black print on some weird (non-gray) background, say, green or yellow (think old paper).</p>
  
  <p>How can I get rid of the green/yellow and receive a gray picture with as much of the gray structure of the original image intact? I.e. I want to keep the gray around the letters for the anti-aliasing effect or for gray areas but I want to turn anything which even is remotely green/yellow to become pure white?</p>
  
  <p>Note that the background is by no means homogeneous; so the algorithm should be able accept a color and an error margin or a color range.</p>
  
  <p>For bonus points: How can I automatically determine the background color?</p>
  
  <p>I'd like to use Python with the Imaging Library or maybe ImageMagick.</p>
  
  <p>Note: I'm aware of packages like <a href="http://unpaper.berlios.de/" rel="nofollow noreferrer">unpaper</a>. My problem with unpaper is that it produces B&amp;W images which probably look good for an OCR software but not for the human eye.</p>