Converting a Phone Photo to Digital Line Art

How to scan a document with your phone

Lots of people are jumping into the #fridayfiveminutemap and posting phone snaps of their maps. A couple have asked how to take a picture of their map and clean it up a little. This mini tutorial should help with that. The basic idea also works for cleaning up scans, and the techniques are useful in a whole range of places (you can find a version of this geared to Gimp users here).

1. The Photo

First I take a photo with my phone of a drawing made with a ballpoint pen. When taking the picture, try to do the following:

Make sure there’s lots of light

This will decrease camera shake and noise and give you the cleanest end result. Note – your phone almost certainly has a white balance built in and will believe that the white paper should actually be a midtone. A picture that’s 99% white will be read by your phone as over-saturated. Hence in this picture the map is mostly around 50% grey. There’s not much you can do about this unless your phone is so advanced you can control it’s white balance (surely only a matter of time…)

Try to make sure that the light is as even as you can get it

Here you can see the bottom left of the image was darker. The more uneven the lighting, the harder you’ll have to work later, so it’s worth taking 5 mins to get this as even as possible.

2. First use of levels

So here I’m using photoshop. However any tool that allows you to adjust the levels in an image (even preview on the Mac – and all photo editing software) can do this. You may even be able to do it on your phone to some extent.

In photoshop I use the layer adjustments dialog and select Levels. This brings up a histogram of the shades in the images. Here you can see a large block in the middle of the range – these are the paper tones. They should all be right up at the right hand end – in the white region. So, we start by moving the white marker (the white triangle) down into the block, and we see a lot of the areas of the image that should be white turning white. However if we go too far we’ll see a lot of the lines start to disappear!

At this stage go as far as you can with the slider without losing your line art in the brighter areas. Then commit the change (merge the adjustment layer down)

3. Dealing with the non-uniform lighting – layer masks

Okay, so the top right looks pretty decent, but the bottom left is still mired in grey. We can’t do a uniform adjustment because we’ll lose detail the bright regions before we gain anything to the bottom left. Thankfully there’s a way around this. The trick is to use layer masks. I create a new adjustment layer (Levels again), and click on the layer mask. To start with it should be all white. Now I take the gradient tool (g) and drag a linear gradient over the area. This creates a gradient where the area I want to target (the bottom left) is white in the layer mask – and the area I want to leave alone (the top right) is black. 3b shows the layer mask blown up a bit bigger. Now when I adjust the levels, I can lighten the bottom left without touching the top right! As most non-uniform lights are diffuse, this form of gradient mask is generally pretty good at handling non-uniform lighting.

4. Rinse and Repeat

Don’t try to do 100% of the correction in one go. Create an adjusment layer, edit the layer mask and adjust the levels to clean up. Rinse and repeat a couple of times and you’ll end up with something cleaner than if you try to get all the way to a clean image in one go.

5. Play!

Once you have the clean line art, you can do whatever you want! Here I’ve turned the image into a multiply layer (so that only the black lines are visible) and placed it over a parchment background. Then I’ve darkened the sea and changed the colour slightly.

The whole process is pretty quick once you’ve done it a couple of times. Once you’re happy with it, you can quickly snap a picture of a sketch and have a pretty digital map in 5-10 mins.

Let me know in the comments if you have questions.

Leave a Reply

Your email address will not be published.