Skip to content

Improve grayscale postprocessing#138

Merged
pynicolas merged 1 commit intomainfrom
better_grayscale
Mar 20, 2026
Merged

Improve grayscale postprocessing#138
pynicolas merged 1 commit intomainfrom
better_grayscale

Conversation

@pynicolas
Copy link
Owner

Apply exp() to the Retinex output before normalization, restoring a linear tone distribution. This improves contrast overall: light gray content is preserved, and dark content stays dark even when the image contains deep blacks. The previous normalization compressed all tones toward the same gray level. Trade-off: shadows and unwanted background variations are also more visible in some images.

Other:

  • stretch toward white using histogram mode
  • fall back to simple normalization on documents with large dark areas
  • add bilateral denoising

Apply exp() to the Retinex output before normalization, restoring a
linear tone distribution. This improves contrast overall: light gray
content is preserved, and dark content stays dark even when the image
contains deep blacks. The previous normalization compressed all tones
toward the same gray level. Trade-off: shadows and unwanted background
variations are also more visible in some images.

Other:
- stretch toward white using histogram mode
- fall back to simple normalization on documents with large dark areas
- add bilateral denoising
@pynicolas pynicolas merged commit 58abc2f into main Mar 20, 2026
5 checks passed
@pynicolas pynicolas deleted the better_grayscale branch March 20, 2026 10:41
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