Abstract: Pattern-matching based document compression systems rely on finding a small set of patterns that can be used to represent all of the ink in the document. Finding an optimal set of patterns is NP-hard; previous compression schemes have resorted to heuristics. We extend the cross-entropy approach, used previously for measuring pattern similarity, to this problem. Using this approach we reduce the problem to the fixed-cost k-median problem, for which we present a new algorithm with a good provable performance guarantee. We test our new algorithm in place of the previous heuristics (First Fit, with and without generalized Lloyd's (k-means) postprocessing steps). The new algorithm generates a better codebook, resulting in an overall improvement in compression performance of almost 17%.
Introduction
When scanning text documents, the resulting image is essentially a collection of repeating shapes—letters, numbers, and punctuation. Modern compression systems exploit this repetition by building a "codebook" (a library of representative patterns) and then simply noting where each pattern appears on the page. However, the efficiency of this method hinges on the quality of the codebook. Most existing systems rely on the "First Fit" heuristic: if a new glyph is "close enough" to an existing pattern, it is grouped there; otherwise, it becomes a new pattern. While fast, this often results in bloated, inefficient codebooks.
Methodology
This research moves away from "good enough" heuristics toward a theoretically grounded algorithm that significantly shrinks document file sizes. The authors introduce a rigorous mathematical framework for partitioning glyphs:
- Cross-Entropy Distance: Instead of simple pixel-matching, a cross-entropy model measures the "distance" between bitmaps, calculating the bits required to describe one bitmap relative to another.
- The Fixed-Cost k-Median Problem: Codebook generation is reframed as a facility location problem. Patterns are treated as "warehouses" with setup costs (bits to store the pattern), and glyphs are "customers" with travel costs (bits to describe the difference between the glyph and the pattern).
- Greedy k-Median (GKM) Algorithm: A new greedy algorithm iteratively selects patterns that provide the best reduction in total document distortion. Unlike previous heuristics, GKM offers a provable performance guarantee, ensuring results within a specific logarithmic factor of the theoretical optimum.
Key Results
The GKM algorithm was evaluated against ten high-quality scanned document pages (CCITT, BROOKS, and LAMBDA datasets). The results demonstrate that GKM consistently produces more efficient codebooks than traditional heuristics.
As shown in the data, GKM produced codebooks that were, on average, 26.2% smaller than those created by the First Fit algorithm. This reduction in library size directly translates to better overall compression ratios.
When considering the final compressed file size—including position and index data—GKM improved performance by approximately 17% on average. With the exception of the CCITT4 test case, GKM consistently outperformed industry-standard heuristics across all metrics.
Discussion and Future Work
One notable finding was that applying Lloyd’s algorithm (k-means) post-processing to GKM actually degraded performance. The authors attribute this to the non-linear, thresholded distance metrics used in document compression, which do not align with the geometric assumptions of k-means.
The primary limitation of the GKM approach is its computational complexity, as it runs in cubic time. While suitable for archival storage, it may be too slow for real-time applications. Future work may involve investigating more efficient data structures to mitigate runtime or incorporating syntactic models (e.g., character frequency and spelling) to further push the boundaries of document compression.
Summary updated