阅读文本 / Reading text
This paper uses synthetic samples to demonstrate the processing method. The code has been verified using examples in an isolated environment; this does not guarantee effectiveness for all real-world files or products. Before processing important files, please retain the original copies and verify them against the boundaries and acceptance criteria outlined in this document.
enlarges the small image by a factor of four, increasing the number of pixels, but strokes that were not originally recorded will not automatically reappear. Resampling can alter edge morphology and may also make it easier for a particular OCR pipeline to process the image; whether recognition improves must be assessed empirically, rather than inferred directly from changes in size.
Size change and information increase are not the same thing
preserves blocky pixels in the nearest-neighbor manner, whereas other filtering methods compute mixed values within the neighborhood. Different methods are suited to different images and purposes; no single filter name can guarantee greater accuracy across all documents. In particular, for binary glyphs, smoothing may introduce gray edges, which subsequent thresholding steps can then alter.
compared with two interpolations of the same input
from PIL import Image
source = Image.new("L", (2, 1))
source.putdata([0, 255])
nearest = source.resize((8, 4), Image.Resampling.NEAREST)
bilinear = source.resize((8, 4), Image.Resampling.BILINEAR)
assert nearest.size == bilinear.size == (8, 4)
assert set(nearest.getdata()) == {0, 255}
assert any(0 < v < 255 for v in bilinear.getdata())
assert list(source.getdata()) == [0, 255]
assert source.size == (2, 1)
The synthetic example demonstrates that interpolation generates intermediate gray levels, but does not restore additional details of the real world. It relies on support
Image.Resampling
the Pillow version. Place the example in a locked environment to avoid mixing the old-version constant syntax with the new-version code.
Before zooming in, first confirm the true limitations.
symptom
first checks
should not directly assume
OCR rejection size
interface long side and pixel limit
The larger it is, the easier it is to pass.
small print blurred
original acquisition resolution
magnification can restore the stroke
High time consumption for large images
total pixels and block partitioning scheme
files are small, so decoding is lightweight
coordinate display offset
Does the shrinking mapping preserve
The output box still belongs to the original image.
Rather than continuously zooming in, it is better to retain the candidate.
generates candidates separately from the same original; do not repeatedly process images that have already been resampled. Recording the scaling ratio, filtering method, and input summary is essential for reproducing the experiment. If a clearer scan can be obtained, re-acquisition should be prioritized over endlessly adjusting interpolation parameters.
separately verifies readability and translation quality
accesses
OmniDoc (Product Entry)
When processing low-resolution scans, first check the recognized text, then examine the translation. If the source text has already been misrecognized, subsequent fluent translations may even render the error more naturally. Tracing through the sequence from recognition to translation is more reliable than simply reviewing only the final draft.
Reference:
Pillow Image.resize
。
- 1 -
Updated 2026-10-08