Recently, I’ve been doing a lot of work on whiteboards. I found whiteboards to be a near-perfect tool for diagraming and planning, but I also needed to be able to save them and view them on my computer.

For a while, I was taking pictures of them, but that seemed very in-elegant and cumbersome. I really wanted some way to “digitize” my whiteboard photos, as if scanning them in.

In my search, I found this excellent post for cleaning up images in GIMP. However, it’s a somewhat involved solution, and I don’t know how to automate GIMP. This quest for an automated solution led me to build this shell script that does the same thing:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

This does the same thing as the GIMP solution, but using Imagemagick instead of GIMP. The basic steps are:

  1. Run a Difference of Gaussians on the image
    • The script uses a large radius (100 pixels) which works well on high resolution images, but might not work so well at lower resolutions
  2. Negates the resulting image, since DoG inverts the color
  3. Normalizes and blurs the image
    • Helps reduce some of the noise in the photo
  4. Further noise reduction by adjusting the levels of the image using some sane defaults

Here are some examples of what it looks like:

Example Input:

Input 1
Input 2

Output:

Output 1
Output 2

I hope this can be of use to someone, somewhere.