Skip to content

feat(image): implement linear-time guided filter for robust document shadow removal - #5

Merged
gzz727007 merged 5 commits into
mainfrom
feat/document-scanner-enhancement
Sep 23, 2026
Merged

gzz727007 merged 5 commits into
mainfrom
feat/document-scanner-enhancement

Conversation

@gzz727007

@gzz727007 gzz727007 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

🦭 Pull Request Description

Summary of Changes

This PR introduces a major upgrade to the document enhancement module (applyDocumentEnhancement) by implementing a linear-time guided filter for robust shadow removal.

Key technical improvements include:

  1. High-Performance Background Estimation: Replaces the legacy approach with a fast guided filter ($O(W \times H)$ time complexity) to efficiently estimate and eliminate uneven lighting and shadows.
  2. Text Stroke Decoupling: Improves foreground/background separation to maintain text sharpness and contrast, preventing text edges from blurring or being over-bleached.
  3. 1px Grid Line Protection: Introduces a structural protection mechanism to preserve extremely fine details, ensuring that thin table borders (e.g., 1px lines in receipts and invoices) are not broken or lost during the shadow removal process.
  4. Single-pass Architecture: Adopts a robust single-pass tone mapping pipeline, avoiding the image degradation and unnatural paper tones caused by multi-iteration approaches.

Type of Change

  • 🐛 Bug fix (non-breaking change fixing an issue)
  • ✨ New feature (non-breaking change adding functionality)
  • ⚡ Performance optimization (rendering, memory, or bundle size)
  • 🎨 UI / UX refinement
  • 🌐 Internationalization / Translations (new or updated language)
  • 📝 Documentation update (README, Guides, Comments)
  • 🧪 Test suite enhancement

🛡️ Privacy & Quality Checklist

  • 100% Client-Side Invariant: All code runs strictly in the browser RAM / WebAssembly. No user documents or telemetry data are ever sent over the network.
  • Automated Tests: I have verified that all existing tests pass (npm test). All 207 image processing tests passed successfully.
  • New Tests Added: I have added unit or E2E tests covering new algorithmic behavior (if applicable).
  • Responsive & Cross-Browser: Verified that UI works smoothly across desktop and mobile screens.
  • Self-Review: I have performed a self-review of my own code and removed unnecessary console.log statements.

Related Issues

Closes #

@gzz727007
gzz727007 merged commit ced985b into main Sep 23, 2026
4 checks passed
@gzz727007
gzz727007 deleted the feat/document-scanner-enhancement branch September 23, 2026 13:44
gzz727007 added a commit that referenced this pull request Sep 23, 2026
…shadow removal (#5)

* feat(scanner): document shadow removal, paper whitening enhancement, and live compare

* refactor(scanner,sign): consolidate scanner parameters and optimize signature processing

* feat(pipeline): expose document scanner enhancement in img2pdf node

* docs: update README and roadmap with scanner enhancement and sign optimizations

* feat(image): implement linear-time guided filter for robust document shadow removal

---------

Co-authored-by: gzz727 <grenguo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant