title: Dust and scratch removal with open source graphic libraries
body: <p>I am trying to automate the cleanup process of a large amount of scanned films. I have all the images in 48-bit RGBI TIFF files (RGB + Infrared), and I can use the infrared channel to create masks for dust removal. I wonder if there is any decent open source implementation of in-painting that I can use to achieve this (all the other software I use for batch processing are open source libraries I access through Ruby interfaces). </p>
  
  <p>My first choice was ImageMagick, but I couldn't find any advanced in-painting option in it (maybe I am wrong, though). I have heard this can be done with MagickWand libraries, but I haven't been able to find a concrete example yet.</p>
  
  <p>I have also had a look at OpenCV, but it seems that <a href="http://docs.opencv.org/modules/photo/doc/inpainting.html" rel="nofollow noreferrer">OpenCV's in-paint method</a> accept only 8-bit-per-channel images, while I must preserve the 16.
  Is there any other library, or even an interesting code snippet I am not aware of? Any help is appreciated.</p>
  
  <p>Samples:</p>
  
  <p>Full Picture</p>
  
  <p><img src="https://i.stack.imgur.com/7YQ8j.jpg" alt="Full Picture"></p>
  
  <p>IR Channel</p>
  
  <p><img src="https://i.stack.imgur.com/vTkkZ.jpg" alt="IR Channel"></p>
  
  <p>Dust and scratch mask </p>
  
  <p><img src="https://i.stack.imgur.com/48wad.jpg" alt="The Mask"></p>
  
  <p>What I want to remove automatically</p>
  
  <p><img src="https://i.stack.imgur.com/YMUke.jpg" alt="To be removed"></p>
  
  <p>What I consider too large to remove with no user intervention</p>
  
  <p><img src="https://i.stack.imgur.com/osT9A.jpg" alt="To be removed manually"></p>
  
  <p>You can also download the original TIFF file <a href="https://dl.dropboxusercontent.com/u/1464091/pa.tif" rel="nofollow noreferrer">here</a>. It contains two alpha channels. One is the original IR channel, and the other one is the IR channel already prepared for dust removal.</p>