Document Image Analysis via Model Checking