A Palaeographer’s Adventures in Programming (1)

I’ve been lax in updating my blog this summer, mainly due to the physical, intellectual and emotional demands of the conference season. However, I’m back at my desk now, and have begun to think about what I should share here. So, I thought I’d track my progress so far in becoming an interdisciplinary scholar: a medievalist doing work in computer science and electrical engineering. The first few months of my year-long study were spent in a kind of interdisciplinary literature review. I have been reading neuroscience articles about age-related conditions in modern-day people, whilst simultaneously researching ageing in the medieval period. I’ve been taking lessons in basic programming, and photographing medieval manuscripts ready for analysis. I have been gathering verbal advice from others, and receiving suggestions of invaluable sources for my study.

       As I passed the mid point of the year-long project, I made the decision to step up the computer science element of my project, by really getting my teeth into some programming. I’m  lucky to be supported in this by my supervisor in electronics and my knowledgeable office-mates. I have decided to record the learning experience here, in the hope that it will aid the absorption process. I’m hoping it will give me incentive to keep up the momentum. However, I also hope it might help or inspire others – at the very least, share with you all a new and, I think, interesting, digital humanities project.

     So, as a reminder, my project title is, ‘Tracing Executive Functioning Impairment in the Handwriting of Medieval Scribes’. It aims the detect and analyse the effects of the movement disorder associated with conditions such as Parkinson’s Disease on the handwriting of scribes. In order to analyse disorder in samples of handwriting, we have to establish which handwriting features are most vulnerable to change due to a given disorder. In my project, this is done using the processes that form part of Optical Character Recognition (OCR): breaking letters down into their constituent parts, and isolating and detecting certain features. We are doing this through the image processing toolbox of a program called MATLAB. Before we can do any kind of analysis, we have to perform ‘pre-processing’ on the images. I like to think of it using the rather silly analogy of exfoliating the skin before putting make-up on…

Pre-processing

      In order to apply any kind of OCR techniques to samples of medieval handwriting, we have to pre-process. Essentially, we need to clean them up and make them ready for the computer to work its magic. ‘Garbage in: garbage out’ definitely applies to image processing, so we have to make sure that the images are suitable. Firstly, we have to convert the colour image into a binary (black and white) equivalent through a process of thresholding. We can also invert the binary image, which I’ve found to be effective in showing the shape of the letter most accurately. We also need to make sure that our image contains the least possible ‘noise’. Noise is the pixels in the image that one is not interested in for the purposes of  image processing. Noise is bad, because it distracts the computer and yields inaccurate results. This is the kind of noisy image that you will be familiar with, I’m sure. As you can see, it is packed with ‘salt and pepper’ noise:

However, for the purposes of optical character recognition, the following is also noisy, because the original image contained unwanted filled pixels above and below the word … marks that are not part of the letters d, i and e.

dieEven a basic level of noise reduction enables us to remove some of these distracting elements, making it – not perfect – but a lot ‘cleaner’:

die2

The problem with pre-processing, for me, was that though OCR articles make reference to it, few explain what it actually comprises. So far, I’ve decided upon a number of processes that I’m using to extract the shape of letters. As mentioned above, the image has been converted to a binary image, and the black and white have been inverted. The next step is to perform a thinning morphological operation on the image, because the shape of the letter that you see above has been affected by the thickness of each pen stroke. By thinning the image, it is possible to remove the effect of the scribe’s pen, and, in theory, just see the shape of the letter itself, as in the example below:

thinimage1341d1The image above demonstrates how successful this thinning process can be in extracting the shape of letters. However, if the image has still not been pre-processed sufficiently, the thinning operation can be unsuccessful:

thinimageYou can see in the letters ‘die’ above that there are still factors interfering with the image: rough edges of each letter, and inconsistencies within the letters themselves. One way in which this problem may be solved is by adding more layers of morphological operations – essentially smoothing out the letters. Of course, this image also shows that the ‘bite’ between the medieval letters has been reflected in the ‘thinned-out’ shape, so it is necessary to separate the letters through a process of ‘segmentation‘. But that’s for another day, another blog post, and a more refreshed palaeographer…

Advertisements

One comment

  1. […] recognition, in order to detect changes in the features of handwriting over time. If you read my last blog post, you might remember that I’d begun to remove the noise in the images so that the […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: