The Inscription Was Worn Smooth by 300 Years of Rain. The AI Read It Anyway.
2026-01-15
10 min read
Tutorial
The Inscription Was Worn Smooth by 300 Years of Rain. The AI Read It Anyway. I was standing in a cemetery in Muğla, western Turkey, staring at a headstone that hadn't been readable by human eyes in probably a century. The marble was pitted, the edges rounded by centuries of wind, and whatever had been carved into it was now just vague shadows under the right angle of sunlight. My phone camera saw it differently. ## How This Started A historian named Dr. Elif Yılmaz contacted me through a mutual friend. She was documenting Ottoman-era graveyards across the Aegean coast — sites that were deteriorating rapidly due to urban expansion, earthquake damage, and simple neglect. Many of these stones carry inscriptions in Ottoman Turkish, Arabic, and occasionally Greek. Some are the only surviving records of entire communities. Her problem was scale. There were over 4,000 stones across 23 sites, many in poor condition. She had two graduate students and a summer. Even with perfect weather and cooperative stone surfaces, manually transcribing 4,000 inscriptions would take years. She wanted to know if OCR could help. ## Why Standard OCR Fails on Stone I tried PaddleOCR and Tesseract out of the box on her sample photos. Both returned garbage. The accuracy was around 12% character-level on the best stones and literally zero on the weathered ones. The reasons are obvious in hindsight. Standard OCR is trained on printed documents — high contrast black text on white paper with consistent fonts. A weathered headstone is the opposite of that: The "text" is carved, not printed. It's a 3D relief, not a 2D contrast pattern. The only way to see it is through shadows, which depend entirely on the lighting angle. The surface is noisy. Lichen, mineral deposits, cracks, and erosion create texture patterns that are indistinguishable from letter strokes at the pixel level. The scripts are historical. Ottoman Turkish uses a variant of Arabic script with additional characters, and the calligraphic styles on these stones don't match any modern font. ## The RTI Trick Before touching the model, I changed the data capture method. Instead of single photographs, I adopted a simplified version of Reflectance Transformation Imaging (RTI). The idea: take multiple photos of the same stone from the same position but with light coming from different angles. In practice, this meant taking 8-12 photos while walking around the stone with a bright flashlight, illuminating it from different directions. Each photo reveals different parts of the carved inscription through shadow patterns. I wrote a script that combines these multi-light images into a single enhanced image where carved features are maximally visible. ```python # Multi-light image fusion for inscription enhancement def fuse_multilight(images): # Convert all to grayscale float grays = [cv2.cvtColor(img, cv2.COLOR_BGR2GRAY).astype(float) for img in images] # Compute local gradient magnitude for each gradients = [] for g in grays: gx = cv2.Sobel(g, cv2.CV_64F, 1, 0, ksize=3) gy = cv2.Sobel(g, cv2.CV_64F, 0, 1, ksize=3) mag = np.sqrt(gx**2 + gy**2) gradients.append(mag) # For each pixel, pick the image with highest gradient stack = np.stack(gradients, axis=0) best_idx = np.argmax(stack, axis=0) # Build fused output fused = np.zeros_like(grays[0]) for i in range(len(grays)): mask = best_idx == i fused[mask] = grays[i][mask] return cv2.normalize(fused, None, 0, 255, cv2.NORM_MINMAX).astype(np.uint8) ``` This alone improved OCR accuracy from 12% to about 41% on the enhanced images. But 41% is still unusable for transcription. ## Fine-Tuning on Stone I needed a model that understood carved text on stone surfaces. I fine-tuned PaddleOCR's detection and recognition models on a custom dataset. For detection training data, I manually annotated 800 inscription regions across 200 stones. The annotations included not just bounding boxes but polygon contours that followed the actual text lines, which on these stones are rarely straight. For recognition, I found a key resource: Dr. Yılmaz had transcriptions of about 300 stones from a 1970s survey, when many inscriptions were still partially readable. I paired these transcriptions with our enhanced photos to create recognition training pairs. The fine-tuned model reached 73% character-level accuracy on enhanced images. For the clearest stones, it was above 90%. For the most weathered ones, around 45% — still not perfect, but enough to give the historians a starting point that they could verify and correct rather than starting from nothing. ## The Stone That Changed Everything Stone #1847 in the Karacasu cemetery. Dr. Yılmaz had photographed it a year earlier and classified it as "illegible — surface completely effaced." It was a flat slab, face-up, that had been walked over for decades. I processed the multi-light captures through the pipeline. The enhanced image showed faint but consistent stroke patterns. The model extracted a partial inscription — a name, a date (1287 Hijri, corresponding to 1870 CE), and part of what appeared to be a lineage. Dr. Yılmaz went quiet for about ten seconds. Then she told me that a local family had been searching for this grave for three generations. The great-grandfather of a man still living in the village was known to be buried in this cemetery, but nobody could identify which stone was his. The name the model extracted matched. I don't usually get emotional about OCR output. That day was different. ## What the Data Revealed Beyond individual stories, the OCR pipeline revealed demographic patterns invisible to individual stone-by-stone study. By extracting dates and locations across all 23 sites, Dr. Yılmaz found clusters of deaths that corresponded to known historical events — malaria outbreaks, the 1899 earthquake, and population movements during World War I. The most haunting pattern was a concentration of child burials in the 1840s across multiple sites, suggesting a disease epidemic that doesn't appear prominently in surviving written records. The gravestones themselves were the only remaining evidence. ## Lessons for OCR Engineers If you're building OCR for non-document use cases, here's what I learned: Your training data matters more than your architecture. PaddleOCR's base architecture was fine. What made it work was domain-specific training data. Preprocessing is half the battle. The multi-light fusion technique contributed almost as much accuracy improvement as the model fine-tuning. Don't ignore the capture method. Perfect accuracy isn't always necessary. A 73% accurate transcription that a historian can correct in 10 minutes is infinitely more valuable than no transcription at all. Don't let perfect be the enemy of useful. And sometimes, the most important thing your model extracts isn't text. It's a connection between a family and their history that would otherwise have been lost forever.
Share this article