Improve quality of old handwritten birth statement with washed ink using OpenCV or Gimp

798 Views Asked by At

I've taken the task to decipher a bit of handwritten text of an old birth/baptism statement (1734), which has washed ink at the bottom of the page (see original photo Chavane.jpg).
More specifically, it is for the erased text, beginning just after the last name entry, Chavane, where you could barely read "Le dix neuf décembre...".. The best attempt our president could do is shown as Chavane2.jpg.
I tried isolating only the erased part, and this should be really our starting point, before applying different techniques (for example these), but my knowledge on image processing is very low, and the result is not much better. The best I could obtain is under clahe_2.png, with this code:

import cv2 as cv
img = cv.imread('Chavane.jpg',0)
# create a CLAHE object (Arguments are optional).
clahe = cv.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
cl1 = clahe.apply(img)

Before trying to erase with Gimp pixel by pixel, I would like to be sure this is really the best base.

1

There are 1 best solutions below

1
On

You can use division normalization in Python/OpenCV to improve the quality.

  • Read the input
  • Convert to grayscale
  • Blur the image
  • Divide the grayscale image by the blurred image
  • Apply unsharp masking to sharpen and increase contrast
  • Save results

Input:

enter image description here

import cv2
import numpy as np
import skimage.filters as filters

# read the image
img = cv2.imread('Chavane.jpg')

# convert to gray
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# blur
smooth = cv2.GaussianBlur(gray, (33,33), 0)

# divide gray by morphology image
division = cv2.divide(gray, smooth, scale=255)

# sharpen using unsharp masking
sharp = filters.unsharp_mask(division, radius=1.5, amount=2.5, multichannel=False, preserve_range=False)
sharp = (255*sharp).clip(0,255).astype(np.uint8)

# save results
cv2.imwrite('Chavane_division.jpg',division)
cv2.imwrite('Chavane_division_sharp.jpg',sharp)

# show results
cv2.imshow('smooth', smooth)  
cv2.imshow('division', division)  
cv2.imshow('sharp', sharp)  
cv2.waitKey(0)
cv2.destroyAllWindows()

Division image:

enter image description here

Unsharp image:

enter image description here