Remove all color but black from an image #

Background removal apps and web-based services don't do well with noisy images like this one of sheet music on thin parchment paper which has text from the next page bleeding through:

Image of sheet music before removing background

However, ImageMagick works, well... magic: $ convert in.png -fill white -fuzz 80% +opaque "#000000" out.png

Image of sheet music after removing background

If the results aren't satisfactory, try tweaking the fuzz value (e.g., 20%). For multiple images, use a for loop: $ for i in *.png; do convert "$i" -fill white -fuzz 20% +opaque "#000000" "$i-out.png"; done

UPDATE: Converted a multi-page PDF to individual PNG images for processing via this Automator workflow (before discovering that the first convert command above works equally well on multipage PDFs):

  1. Files & Folders > Ask for Finder Items
  2. PDFs > Render PDF Pages as Images
  3. Files & Folders > Rename Finder Items > select Make Sequential from dropdown
  4. Files & Folders > Move Finder Items > select Destination directory

/nix | Feb 02, 2018

Subscribe or visit the archives.