A way to process photos of a whiteboard

This is the description of an easy way to process cell phone photos of whiteboards for inclusion in informal documentation. The common scenario is a handful of people discussing around a whiteboard, the discussion reaches its conclusion, a photo is quickly taken to document the ideas before everybody forgets it all. That photo will usually look quite different from how the mind perceives the board, is ceiling lights and windows usually cause reflexes which are mentally easy to filter away.

A simple solution is to do a low frequency filtering of the photo, divide the original filter by the filtered data (leaving only high frequency components, i.e. whiteboard marker lines), then do a threshold filter to get a 1-bit picture.

Original picture

The original may have subjectively looked something like the example below, boxes and arrows:

subjective original

Unfortunately, the photo will usually come out something like this:

simulated photo

Processing the whiteboard photo with Gimp

The use of Gimp here is to make the process easy to illustrate, this can just as easily be done with your favorite image processing library and/or favorite numerical library and/or favorite programming language with the appropriate core features. I like using Pillow and Numerical Python, but that's 95% personal preference and little else.

So, load up the picture in Gimp, and first, make a new layer from the entire picture: Layer → New from visible

Make only the top-most picture in the list of layers visible:

widgets for visible layers

Now, for the low-pass filter. I choose a Gaussian blur (Filters → Blur → Gaussian Blur...), and adjust it till the high-frequency elements, that is the actual diagram, are no longer visible:

result of aggressive low-pass filtering

Now, make both layers visible again, and choose Mode → Divide for combining the layers:

original divided by low-pass filtered version

I think this already looks a lot better, but the uneven color of the letters, and the remnants of the halo around where the reflection was is a problem.

Let's do a quick Image → Flatten Image before we move on. So, what happens if a thresholding is optimistically applied with the current data? (Colors → Threshold...)

thresholding with artifacts

As we can see, artifacts from the halo become visible before “blob number 3” is completely reconstructed. This picture is now so clear that many filtering and detection mechanisms will work, but why not do it the easy way and exploit the fact green marker was used? (Colors → Curves)

image with strongly reduced intensity of the green channel

Then, for a second attempt at the thresholding operator (Colors → Threshold...):

thresholding after color channel manipulation

Finally a picture which can be included in the notes without too much hassle.

2020-08-14, Steinar Knutsen