DIVADid - Document Image Degradation

The Did of DIVADID stands for Document Image Degradation. It is a method developed by the DIVA group (University of Fribourg) with the goal of providing an easy-to-use method to generate locally realistic degradations on historical document images.

The main goal of degrading historical document images is to generate additional training data from ground-truthed images, i.e., images for which the expected results of some processing methods is known. Generating the ground truth of a document image is usually a time-consuming task, therefore being able to get more training data for less manual work is an attractive option.

Degradation Method Description

With this degradation method, we propose to paste degradation patches on the target document in the gradient domain. The gradient domain of an image corresponds to the difference between the values of pixels. Thus, applying gradient-domain degradation patches, i.e., the differences of pixel values due to the degradations, is a good approximation of applying the effect of the degradation.

The following six images illustrate the process. A coffee staint is used for having better-looking gradient-domain representations - stains from real historical documents can also be used.

Input image Input degradation
Image in the gradient domain. Degradation in the gradient domain.
Combination of image and degradation in the gradient domain.
Final result, in the color domain.

Advantages

Real degradation patches can be used, therefore the users can select to add degradation looking similar to the ones in the documents they want to process.

As differences of values are pasted, the color of the background of the degradation patches does not matter.

Working directly on color images, there is no need for pre-processing, text detection or any content-dependent step.

Disadvantages

Pasting the degradations at random locations decreases the global verisimilitude of the degradation pattern. For example, fingerprints usually appear at locations where readers manipulated pages for turning them, that is near the sides, not right in the middle of a paragraph.

Reconstructing an image from gradient maps can be time consuming, as it has to be done in an iterative way.

Download

DIVADid is provided as an open source software under the LGPL v3 license. You can get:

  • The source code, a compiled version and the necessary libraries here,
  • Or the source code only on Github.

The source code has been compiled and tested with Java 1.8 (both the Oracle version and OpenJDK). Unless you intend to use the OpenCL acceleration, there is no need to install anything special.

Useful Additional Stuff

We have extracted a few degradation patches from documents images found on E-Codices:

How To's

DIVADid uses XML scripts describing the desired degradation process. Gradient-domain degradations can be applied in two ways: first by selecting the degradation quantity and a folder containing degradation patches, second by specifying manually the location of degradation patches.

Let us assume that we want to degrade the document image "input.png", using degradation patches stored in the "degradation-folder" folder. Here is an xml script doing just that:


<procedure id="degradation-example">
    <image id="img">
        <load file="input.png"/>
    </image>
    <gradient-degradations ref="img">
        <density>2</density>
        <strength>0.85</strength>
        <source>degradation-folder</source>
        <single-core/>
        <iterations>800</iterations>
    </gradient-degradations>
    <save ref="img" file="output.png"/>
</procedure>

Where "density" indicates the average number of degradation patches overlapping each pixel, "strength" a multiplication factor for the degradations, "single-core" indicating that a single process should be used for the reconstruction, and "iterations" how many reconstruction steps have to be done.

Start the program with the script as parameter:

java -Xmx4G -jar DivaDid.jar script-file-name.xml

More detailed information is provided in the documentation provided with DIVADid.