What techniques work for reading poor or illegible images of a source? Turning the source into a negative is one that's often quoted but what other techniques are valuable, and in what circumstances?
-
Are you limiting your question to digital images? or should answers also address photos, photocopies, microfilm?– bgwiehleApr 9, 2014 at 20:03
-
@bgwiehle, I'm interested in all forms of imaging of sources.– user104Apr 10, 2014 at 6:48
-
3Relevant: mathematica.stackexchange.com/q/17125/8– VerbeiaApr 12, 2014 at 2:24
4 Answers
Full disclosure: I am a moderator on Mathematica.SE, but have no relationship with the company that makes the product
Surprising is it might seem, the Mathematica application has extensive image editing functionality that can be used for this sort of task. The language might take a bit of getting used to, but you can learn a lot just by mucking around and reading the extensive documentation, especially this and this. And the Home Use version costs a lot less than PhotoShop.
To give an example of how to use it, here is a crop from a parish record from north-west Kent.
rawimage =
ImageCrop[ImageCrop[ImageCrop[Import["~/Desktop/LoftWaldron.png"],
{1800}, Left], {Full, 750}, Top], {Full, 400}, Bottom]
I can make out that this recorded the marriage of John Loft and Sarah Waldron, but I can't quite make out her parish. There is no one right way to approach this, but here are a few commands to try. First, MinFilter
spreads out dark regions to near neighbour pixels. This smears the printed text but darkens the handwritten text.
MinFilter[rawimage, 1]
Blurring the result using a GaussianFilter
or similar surprisingly makes the image easier to read, and also helps fill in some areas where the ink is illegible.
GaussianFilter[MinFilter[rawimage, 1], 5]
Sharpening again from here helps pick out details a bit better.
Sharpen[GaussianFilter[MinFilter[rawimage, 1], 5], 3]
Depending on the image, you may need to fiddle with the parameters. You can even use the Manipulate
command to automatically make a sliders-and-buttons mini-app to play around with it.
And of course you can name intermediate results like this:
gaussianed = GaussianFilter[MinFilter[rawimage, 1], 5];
Sharpen[gaussianed, 3]
The particular image I've used here will never be completely legible, but one can now be more certain that the last four letters are nham. According to this list of Kent parishes, there are eight ending in that letter combination. Looking at the earlier letters, it could be Sydenham. The first letter looks more like an S than a T, but I can't completely rule out Twickenham in Middlesex.
If you're scanning a document yourself, make sure you scan with adequate resolution. For a typical document, 300 dpi is usually adequate, but if there are issues with document readability, 600 dpi would be better. You can scan in color or grayscale, but most written documents gain little from using color (except a bigger file and slower processing). Some scanning software has a black & white (B/W) mode (which may be called "document" or "fax", as opposed to "B/W photo", which is grayscale). If so, avoid it and use a grayscale (or color).
If a document has severe readability problems, adjusting the scan boundaries so that only the original paper is included may be helpful. Typically the default boundaries include some areas at the edges which show white platen or black areas, and these are usually more extreme intensities than the document itself; by excluding them from the scan, the results may include a broader range of values from the document itself, which is what is relevant for readability.
A photo editing program is usually helpful; I use the free Gimp program. Although contrast and brightness adjustments can be helpful, they are usually hard to adjust in a satisfactory way. Instead, the most useful operation seems to be which often called "Levels" adjustment.
"Levels" often has a "automatic" button or mode where the program sets the controlling values. Try this first as it may do all that you need done, or give you a starting point for manual control; sometimes it will be of little help.
One major "Levels" control is setting the black and white points to be used. In Gimp and other programs these values can be set by sliding markers underneath a histogram of the image. The histogram is a graph showing how many pixels have each particular brightness. Essentially you want to narrow the markers so that they are closer together while keeping most of the pixels between them. Anything below the low setting will come out black and anything above the high setting will be white. What this does is increase the contrast of the writing, which will be darker, with the paper, which will be lighter. This very much improves legibility, which can especially poor where originals were yellowed with age or on colored paper, or written with light marks, as from pencil.
The other significant "Levels" control is usually called "midpoint" or "gamma". This is an adjustment which compensates for exposure. It sets where the midpoint of grayness should be, and smoothly adjusts all the values between the black and white setpoints. First choose rough black and white setpoints as previously described, then adjust the gamma or midpoint. In Gimp, this is a sliding marker between the black and white markers. This can have a large effect and will often substantially improve the result you see. You can then fudge the three controls around until you get an acceptable or best-achievable result.
Other image operations I find don't usually add much value for documents (photos are different). I rarely find the "negative" operation useful except to invert a negative image into a positive one. Occasionally when using an online reader that has few options, using "negative" to turn the light background dark can be helpful to perceive the nature of a mark. Usually this helps only when the exposure level is problematic generally.
If you ever have to deal with an old-time projecting microfilm reader, good luck, but one thing that sometimes helps is to put a piece of yellow paper on the projection surface; the color may make the contrast a bit better (or may not).
There is not going to be any one answer as each image is different and has different needs.
I use Photoshop but these comments should apply equally to other image editors like Photoshop Elements or Gimp.
1: Convert to Black and white (even though it is a B&W image) and then use the Red Green & Blue colour channel adjusters to tweak the colour conversion a bit more.
2: Use a filter to remove noise
3: Try inverting the image as you have already stated
4: Try altering the contrast and brightness
5: Try adjusting the levels
6: Adjust the colour curve
7: Apply sharpening
Also make multiple layers with different edits applied to each layer and then blend the layers together.
This becomes more about image editing than anything else. There are some other tricks that can be used like using masking to apply some of the tools above to only a section of the scanned document.
A trick I use, when I have the patience, is to use a photo retouching application. I find Paint.net or Picasa the easiest and they are both freeware.
If you use a combination of the edge detection, sharpening and colour flattening tools you can often bring dodgy handwriting up clear enough to be able to make it out.
Be warned though, it can take a bit of tweaking and eyestrain to get a good result. Although sometimes it will come up very quickly.