Guides · Advanced
Compression Before OCR
"Compression before OCR" covers the decisions about how a scanned page image is encoded — losslessly or lossily, in bilevel or continuous-tone form, or as a layered Mixed Raster Content container — before an OCR engine reads it. Compression shrinks files for storage and transmission, while OCR depends on the fidelity of character edges and stroke shapes; lossy encoding that looks acceptable to a human can degrade or, in the documented Xerox JBIG2 case, silently substitute glyphs. The main families are continuous-tone coders (JPEG, JPEG 2000), bilevel/facsimile coders (CCITT Group 4, JBIG, JBIG2), and the Mixed Raster Content (ITU-T T.44) model. Lossless bilevel (Group 4, lossless JBIG2) and visually lossless JPEG 2000 are preferred for material destined for recognition or preservation, and archival regulators (NARA, FADGI, BSI) constrain lossy document compression accordingly.
By PrinterArchive EditorialEdited by PrinterArchive Editorial
History and origin
Compression of document images grew out of facsimile standardization at the CCITT (now the ITU-T Telecommunication Standardization Sector). CCITT Group 4 bilevel fax coding was first standardized as ITU-T Recommendation T.6 in 1984 (with a later 1988 edition), using the two-dimensional MMR (Modified Modified READ) scheme, which is lossless for black-and-white images and remains embedded in TIFF, CALS, and PDF.
Bilevel coding continued with JBIG (Joint Bi-level Image Experts Group) and then JBIG2, published as ITU-T T.88 (February 2000) and ISO/IEC 14492 (2001), which added symbol-dictionary and lossy modes. For continuous-tone material, JPEG was approved as ITU-T T.81 (September 1992), with the corresponding ISO/IEC 10918-1 published in 1994; JPEG 2000 followed as the ISO/IEC 15444 family from December 2000. The layered Mixed Raster Content (MRC) model was standardized as ITU-T Recommendation T.44 (first approved 1 April 1999) and ISO/IEC 16485:2000.
The practical importance of compression as a distinct pre-OCR concern was crystallized by the 2013 Xerox scanner incident, the most widely documented real-world case of a compression choice altering document content.
What problem it solves
Scanned pages are large, and a repository of millions of pages is otherwise unmanageable for storage, transfer, and delivery. Compression before OCR addresses several needs:
- Storage and bandwidth — shrinking archival masters and access derivatives.
- Pipeline throughput — smaller images move faster between capture, storage, and the OCR stage.
- Container packaging — producing searchable PDFs in which the page image and the OCR text layer coexist at a reasonable file size. Bilevel coders such as Group 4 and JBIG2 and the layered MRC model are used precisely to keep such PDFs small.
The design goal is to obtain these savings without removing the visual information that the OCR engine and the human reader rely on.
How it works
Three encoding strategies are applied to document rasters.
Bilevel (1-bit) coding. After binarization, each pixel is black or white. Facsimile coders (Group 4 / T.6 / MMR) exploit run-lengths and vertical correlation between scan lines; they are lossless with respect to the bilevel image. JBIG2 goes further by treating repeated marks (letters) as reusable symbols.
Continuous-tone coding. JPEG and JPEG 2000 transform image blocks or wavelet subbands and quantize the resulting coefficients. JPEG is lossy in its common baseline mode; JPEG 2000 supports both lossy and mathematically lossless modes.
Layered decomposition (MRC). The page is split into a binary selector/mask plus continuous-tone foreground and background layers, each coded with the codec best suited to it.
OCR operates on the decoded image. If the codec discarded or altered edge detail, the recognizer inherits that damage, which is why lossless or visually lossless coding is preferred for material destined for recognition and preservation.
Algorithms and variants
CCITT Group 4 (T.6 / MMR). Lossless, bilevel only. Its 2-D encoding derives from Group 3's Modified READ, itself built on Modified Huffman coding. It is widely embedded in TIFF, CALS, and PDF.
JBIG2 (T.88 / ISO/IEC 14492). Segments the page into text, halftone, and generic regions.
- Symbol dictionary: for text, one representative bitmap per distinct symbol is stored and then referenced across the page.
- Pattern Matching & Substitution (PM&S): a lossy mode that replaces each mark with a matching dictionary symbol; it can introduce substitution errors.
- Soft Pattern Matching (SPM): stores refinement data encoding the difference between the actual mark and the dictionary symbol, reducing substitution errors.
- Generic region coding uses the MQ arithmetic coder — the same coder used in JPEG 2000 — or Huffman coding.
Per figures published with the standard and cited by Wikipedia, lossless JBIG2 typically produces files 3–5× smaller than Fax Group 4 and 2–4× smaller than JBIG; these are standards-body/press figures rather than independent benchmarks.
JPEG (T.81 / ISO/IEC 10918-1). Block-DCT with quantization; baseline mode is lossy. Aggressive quantization produces ringing and "mosquito" artifacts along the high-contrast edges of text.
JPEG 2000 (ISO/IEC 15444). Wavelet-based, supporting both lossy and lossless coding, with rate control toward a target compression ratio. It is the codec archival guidance permits for visually lossless masters.
Mixed Raster Content (T.44). A binary selector/mask picks, per pixel, between a foreground and a background continuous-tone layer. Per the standard the mask may be coded with T.4/JBIG/JBIG2 and the image layers with JPEG/JBIG1/run-length. MRC underpins small searchable/scanned PDFs; DjVu uses the same layered principle (with its own JB2 and IW44 codecs) rather than implementing T.44.
Where it sits in the capture/OCR pipeline
A typical order is: scan → preprocessing (deskew, binarize, denoise) → encode/compress → store/transmit → decode → OCR → package (searchable PDF).
The compression choice can appear twice: as the coding of the archival master or working image fed to OCR, and as the coding of the page image inside the output PDF alongside the recognized text layer. Binarization and bilevel compression (Group 4, JBIG2) are often coupled — the same binarization that helps OCR also enables the smallest bilevel encodings.
Advantages
- Large storage and bandwidth savings, especially from bilevel (Group 4, JBIG2) and layered (MRC) coding of text-dominant pages.
- Lossless options preserve recognition fidelity. Group 4 and lossless JBIG2 shrink files without altering pixels, so OCR sees exactly the source image.
- Layered MRC keeps color and grayscale scanned PDFs small while retaining sharp text via the binary mask.
- Standardized and widely supported across TIFF, PDF, and fax ecosystems, aiding interoperability and long-term readability.
Limitations and failure modes
- Lossy JPEG degrades text edges. Higher compression introduces smudging and ringing around characters, reducing recognition accuracy; guidance recommends lossless formats where OCR quality matters.
- Lossy JBIG2 (PM&S) can substitute characters. The most serious documented failure: pattern matching can replace one glyph with a visually similar but different one (for example, 6↔8), producing output that looks correct at first glance yet is factually wrong. For this reason OCRmyPDF removed its lossy JBIG2 option, citing "the well-known risk of character substitution errors," and now uses lossless JBIG2, falling back to CCITT.
- MRC segmentation artifacts. Poor mask segmentation causes halos around objects and can compromise soft edges and scanned tonal data.
- Generation loss. Re-compressing an already-lossy image further harms OCR.
- Codec constraints in older MRC. T.44 permits only older standardized codecs for its layers, limiting efficiency versus modern alternatives.
Relationship to OCR and scanning
OCR accuracy is bounded by input fidelity. Lossless bilevel and continuous-tone coding is neutral to OCR, since the recognizer sees the original pixels. Lossy continuous-tone coding trades edge sharpness for size and can lower recognition accuracy as the compression level rises.
Lossy symbol-substitution coding (JBIG2 PM&S) is uniquely dangerous because it can change content rather than merely blur it — the failure is not "unreadable text" but "confidently wrong text," which OCR then faithfully transcribes. The practical rule in capture engineering is to compress losslessly, or visually losslessly, anything intended for recognition or preservation, and never to use lossy symbol substitution for documents where exact characters — especially numbers — matter.
Relationship to PDF and archival
Searchable PDFs commonly pair a compressed page image (Group 4 or JBIG2 for bilevel; JPEG, JPEG 2000, or MRC layers for color/gray) with an invisible OCR text layer.
Archival policy is explicit about lossy document compression. The U.S. National Archives (NARA), under 36 CFR Part 1236 Subpart E (effective June 5, 2023), does not accept digitized permanent records saved with lossy compression such as JPEG or JBIG2; it permits visually lossless JPEG 2000 with a compression ratio not to exceed 20:1, subject to visual artifact testing.
The Federal Agencies Digital Guidelines Initiative (FADGI, Technical Guidelines 3rd Edition, finalized 2023) grades image quality on a star scale and ties OCR suitability to its tiers, with lower tiers not necessarily meeting OCR requirements; it treats lossless JPEG 2000 as competitive with TIFF for archival masters.
In Germany, BSI Technical Guideline TR-03138 (RESISCAN), effective 16 March 2015, prohibits lossy JBIG2 (both Pattern Matching & Substitution and Soft Pattern Matching) for legally-significant substitute scanning, where the paper original is destroyed; lossless, non-pattern-matching JBIG2 is unaffected.
Modern relevance
Bilevel and layered compression remain standard in high-volume document capture, multifunction-printer scan-to-PDF, and mass-digitization programs. Lossless JBIG2 and Group 4 continue as default bilevel encodings in tools such as OCRmyPDF, where the former lossy JBIG2 flags are now ignored with a warning.
The 2013 Xerox episode continues to inform preservation policy: NARA, FADGI, and BSI have codified prohibitions or limits on lossy document compression, and OCR-oriented tooling defaults to lossless or visually lossless coding. JPEG 2000's rate-controlled, visually lossless mode is the sanctioned compromise for color and grayscale masters where pure lossless coding is too large.
Timeline
1984
CCITT Group 4 (ITU-T T.6, MMR) first standardized (later 1988 edition); lossless bilevel fax coding.
1992
JPEG approved as ITU-T T.81 (ISO/IEC 10918-1 published 1994).
1999
ITU-T T.44 (Mixed Raster Content) first approved; ISO/IEC 16485:2000 follows.
2000
JBIG2 published as ITU-T T.88; JPEG 2000 (ISO/IEC 15444) begins.
2001
JBIG2 published as ISO/IEC 14492.
August 2013
David Kriesel reports number substitutions (e.g., 6→8) on Xerox WorkCentre/ColorQube devices, traced to lossy JBIG2 pattern matching; per his account Xerox confirms and issues patches disabling pattern matching (dates from Kriesel's timeline).
March 2015
BSI TR-03138 (RESISCAN) prohibition of lossy JBIG2 for legally-significant substitute scanning takes effect.
2023
NARA digitization rule (36 CFR 1236 Subpart E) effective June 5; FADGI Technical Guidelines 3rd Edition finalized.
Recent OCRmyPDF releases
lossy JBIG2 mode removed; the corresponding flags are ignored with a warning.
Frequently asked questions
- Is it safe to use JBIG2 compression before OCR?
- Lossless JBIG2 is safe because it does not alter pixels, so OCR sees the original image. Lossy JBIG2 in Pattern Matching & Substitution (PM&S) mode is risky: it can replace one glyph with a visually similar but different one (for example 6 and 8), producing confidently wrong text. Tools such as OCRmyPDF removed their lossy JBIG2 option for this reason and now default to lossless JBIG2, falling back to CCITT Group 4.
- Does JPEG compression hurt OCR accuracy?
- Baseline JPEG is lossy and introduces ringing and 'mosquito' artifacts along the high-contrast edges of text. As the compression level rises, these artifacts blur character edges and can reduce recognition accuracy, which is why guidance recommends lossless or visually lossless formats for material destined for OCR.
- What compression do archival standards allow for OCR-quality scans?
- NARA's 36 CFR Part 1236 Subpart E (effective June 5, 2023) does not accept permanent records saved with lossy compression such as JPEG or JBIG2, but permits visually lossless JPEG 2000 at a compression ratio not exceeding 20:1 with visual artifact testing. FADGI treats lossless JPEG 2000 as competitive with TIFF for archival masters, and Germany's BSI TR-03138 (RESISCAN) prohibits lossy JBIG2 for legally-significant substitute scanning.
- What is Mixed Raster Content (MRC) and how does it relate to OCR?
- MRC (ITU-T T.44 / ISO/IEC 16485:2000) is a layered model that splits a page into a binary selector mask plus foreground and background continuous-tone layers, each coded with a suitable codec. It keeps color and grayscale scanned PDFs small while retaining sharp text via the mask, which supports OCR. DjVu uses the same layered principle with its own codecs rather than implementing T.44.
Source transparency (14 sources)
These references support claims made in this entry. The archive uses verified institutional and public-domain sources only; see Source policy.
Sources consulted (14)
- ITU-T T.6 (Group 4) format description — Library of Congress
- ITU-T T.81 (JPEG) Recommendation — ITU-T / W3C
- ITU-T T.88 (JBIG2) Recommendation — ITU-T
- ITU-T T.44 (Mixed Raster Content) Recommendation — ITU-T
- ISO/IEC 16485:2000 (Mixed Raster Content) — ISO
- JBIG2 — Wikipedia
- JPEG 2000 — Wikipedia
- Group 4 compression — Wikipedia
- Mixed raster content — Wikipedia
- 36 CFR 1236.48 — Digitizing Permanent Federal Records — U.S. eCFR / NARA
- Federal Records Management: Digitizing Permanent Records (final rule) — Federal Register / NARA
- 3rd Edition of FADGI Still Image Digitization Guidelines Finalized — Library of Congress, The Signal
- Installing the JBIG2 encoder (lossless vs lossy discussion) — OCRmyPDF documentation
- Xerox WorkCentres are switching written numbers when scanning — David Kriesel
Continue in the archive
Related reading
Tools
TIFF (Tagged Image File Format)
A tag-based container format for raster images, developed in the desktop-publishing era and standardized at Revision 6.0 (1992), now owned by Adobe.
Tools
PDF/A
PDF/A (ISO 19005) is the archival subset of PDF for long-term preservation, using embedded fonts, device-independent color, and standardized metadata.
Workflows
Scan to Searchable PDF
A repeatable workflow for turning paper documents into searchable, archival PDF files using scanning and OCR.
Guides · Advanced
Image Binarization
Converting grayscale document scans to bilevel black/white via global and local thresholding (Otsu, Niblack, Sauvola) for OCR and archival.
Modern tools
Contemporary apps for the same task, published by HELPERG LLC — the publisher of this archive.

PDF Editor & Convert
Edit, convert, combine, and OCR PDF documents.

ZIP & RAR
Open, create, and extract ZIP and RAR archives on a phone or tablet.