fix: OCR embedded image regions selectively instead of full-page render - #221
Open
AdemBoukhris457 wants to merge 1 commit into
Open
fix: OCR embedded image regions selectively instead of full-page render#221AdemBoukhris457 wants to merge 1 commit into
AdemBoukhris457 wants to merge 1 commit into
Conversation
Contributor
|
I don't disagree with this change, but some complex/annoying merge conflicts popped up based on past PRs |
AdemBoukhris457
force-pushed
the
fix/selective-image-region-ocr
branch
from
May 26, 2026 08:35
0f2a48d to
52d02ef
Compare
Contributor
Author
@logan-markewich Just rebased on main and took care of the conflicts. Should be good to go now |
On text-heavy pages with embedded images, OCR each image region via render_image_object() rather than rendering and OCRing the entire page. Sparse pages (<100 chars) still use full-page OCR. Co-authored-by: Cursor <cursoragent@cursor.com>
AdemBoukhris457
force-pushed
the
fix/selective-image-region-ocr
branch
from
May 26, 2026 08:49
52d02ef to
fb7c951
Compare
|
Just noting a edge case scenario, Sometimes, the PDF creating software will split the image and them embed it into the PDF. Check this PDF for instance Interesting pages
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #220
Summary
render_image_object()instead of rendering and OCRing the entire page< 100chars native text) still use full-page OCR (scanned / image-only pages)Motivation
Previously, any page with an embedded image (logo, icon, figure) triggered full-page OCR even when the page already had plenty of native text.
image_bounds()was only used as a boolean trigger; image boxes were never used for cropping or regional OCR.This caused unnecessary render + OCR cost on decks and reports where every slide has a small logo.
Documentation alignment
Code now matches documented selective OCR behavior:
LiteParseConfig: runs on text-sparse pages and embedded images — image OCR is now scoped to those regions, not the whole pageBehavior change
< 100chars≥ 100chars + images≥ 100chars, no imagesTest plan
cargo test -p liteparse --no-default-features ocr_merge(8/8 pass, incl. bbox mapping tests)--no-ocr— unchanged