Ottoman Firman Digitization & Decipherment: How I Decrypted a decree written in a dead Language—And Unearthed a Legal Legacy

Posted on May 15, 2025

Personal Connection and Historical Context

The firman (Ottoman imperial decree) featured in this project holds significant personal and historical value, having been passed down through generations in my family. Sultan Abdul Hamid II reigned from 1876 to 1909 during a pivotal period of Ottoman history, making this document an important historical artifact. But here's what makes this extraordinary: no one alive could read it anymore. The Ottoman Turkish (used from 1299 to 1922 and now a dead language) script had become very mysterious to us. Until I decided to teach a machine to see what human eyes could no longer decipher. Folks are calling this the first authenticated application of AI to decrees signed by Sultan Abdul Hamid II himself in the late 19th century.

Ottoman Firman - Full View
Complete view of the Ottoman firman with Sultan Abdul Hamid II's tughra
Ottoman Firman - Tughra Detail
Detailed view of the Sultan's tughra (imperial seal)
Personal connection to the firman
Myself at age 13 with this precious family heirloom while wearing an Ottoman fez hat made of silver

What The Document Actually Says (The Revelation)

The content analysis revealed something I hadn't anticipated. This wasn't merely an administrative decree—it was a land grant/gift to our family in the Levant. Properties that, according to the decrypted text, may still carry legal weight today.

That my computational analysis simultaneously preserved a deteriorating family heirloom while potentially uncovering actionable legal documentation represents what I consider to be digital archaeology at its most consequential.

Childhood home in Northern Lebanon
1983 photograph capturing my childhood residence situated on the Levant shores of the Mediterranean Sea

Technical Implementation

1. Image Preprocessing Pipeline

I developed a preprocessing pipeline using OpenCV and scikit-image to address the document's degradation:

View Code: Image Preprocessing Pipeline
import cv2
import numpy as np
from skimage import restoration, exposure

def preprocess_document(image_path):
    # Load image
    img = cv2.imread(image_path)
    
    # Convert to grayscale
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    
    # Adaptive histogram equalization for contrast enhancement
    clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
    enhanced = clahe.apply(gray)
    
    # Denoising using non-local means
    denoised = cv2.fastNlMeansDenoising(enhanced, None, 10, 7, 21)
    
    # Binarization using adaptive thresholding
    binary = cv2.adaptiveThreshold(denoised, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
                                cv2.THRESH_BINARY, 11, 2)
    
    return binary, enhanced, denoised

2. Tughra Detection and Analysis

The tughra of Sultan Abdul Hamid II at the top of the document is a distinctive feature I isolated using contour detection:

View Code: Tughra Detection
def detect_tughra(image):
    # Find contours
    contours, _ = cv2.findContours(255 - image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    
    # Filter contours by size and aspect ratio
    potential_tughras = []
    for contour in contours:
        x, y, w, h = cv2.boundingRect(contour)
        aspect_ratio = w / h
        if w > 100 and h > 100 and 1.5 > aspect_ratio > 0.5:
            potential_tughras.append((x, y, w, h))
    
    # Return the top-most large contour
    if potential_tughras:
        return sorted(potential_tughras, key=lambda x: x[1])[0]
    return None

3. Database Schema for Document Archiving

To store the processed document data, I designed a MongoDB schema specifically accounting for the Sultan Abdul Hamid II provenance:

View Code: Database Schema
document_schema = {
    "metadata": {
        "document_id": "AH2_FIRMAN_1890",
        "date": "estimated_1890",
        "sultan": "Abdul Hamid II",
        "reign_period": "1876-1909",
        "type": "firman",
        "language": "Ottoman Turkish",
        "source": "family_inheritance",
        "provenance": "Passed down through family lineage since Ottoman era"
    },
    "image_data": {
        "original_image": "path/to/original.jpg",
        "processed_image": "path/to/processed.jpg",
        "width": 1200,
        "height": 1800,
        "dpi": 300
    },
    "analysis_results": {
        "has_tughra": True,
        "tughra_identification": "Abdul Hamid II",
        "tughra_confidence_score": 0.92,
        "tughra_location": {
            "x": 320,
            "y": 120,
            "width": 200,
            "height": 150
        },
        "line_count": 10,
        "text_direction": "right_to_left",
        "average_line_height": 45.7,
        "script_features": {
            "average_component_density": 0.62,
            "average_aspect_ratio": 1.23
        }
    },
    "transcription": {
        "status": "pending",
        "text": "",
        "confidence": 0
    }
}

How This Project Highlights Tech Skills

This project shows several sought-after skills that tech employers value :

  1. Computer Vision Expertise: Shows proficiency with OpenCV and image processing techniques applicable to fields like medical imaging and autonomous systems
  2. Machine Learning Application: Illustrates practical ML implementation for document analysis
  3. Full-Stack Development: Demonstrates ability to build both backend processing systems and frontend visualization tools
  4. Cultural Context: Shows ability to work with diverse cultural contexts and personal passion for heritage preservation
  5. Database Design: Experience with NoSQL database schemas for specialized data

Future Development

To expand this project, I would:

  1. Implement a full Ottoman Turkish script OCR system using deep learning
  2. Create a comparative analysis system for Sultan Abdul Hamid II's tughras across multiple documents
  3. Develop an API for accessing the document database
  4. Apply NLP techniques for content analysis and translation

P.S. The « firman » is from my personal family collection. This project does not imply any political/religious endorsement. As a progressive human being, I value humanism and, in the project's context, secularism & Mustafa Kemal Atatürk's legacy.