Skip to content
GPU-assistedUpload required

Remove Shadows from a Photographed Document

Photograph a page and you photograph your own shadow with it. A threshold cannot fix that, because a threshold only knows how dark a pixel is, and shaded paper is darker than sunlit ink. What separates them is not brightness but size — shadows are broad and change slowly, letters are small and change abruptly. This runs an operation that sorts by exactly that, and no model of any kind is involved.

Use this without the search next time. Prathom Workbench puts Prathom's tools in your toolbar.

Add to Chrome — free

Drop an image here, or click to browse

Up to 25 MB. Uploaded temporarily, deleted after processing.

GPU-assisted — results vary slightly between runs.

What it does

  • Background subtraction rather than thresholding
  • No generative model, so no character can change
  • Uneven and gradient lighting flattened
  • Output around two megapixels

How to use Remove Document Shadows

  1. 1

    Photograph the page as flat as you can

    This corrects lighting, not geometry. A page shot at an angle stays at an angle, and a curled page keeps its curl.

  2. 2

    Run the flattening

    The image is scaled to about two megapixels, the lit paper is estimated and subtracted, and what is left is inverted back to dark text on white.

  3. 3

    Check anything large and solid

    Headings, logos, filled table cells, and photographs are the things this can lose. The body text is the part that always survives.

How it works

Your image is scaled so its total area is around two megapixels, keeping the original proportions. Then a single morphological operation does the work, followed by an inversion and a contrast adjustment.

There is no model here. No diffusion, no sampler, no prompt, no seed. The graph is four image operations in a row, and the output is a deterministic function of the input — the same file always produces the same result, because there is nothing in the chain that could produce anything else.

Separating by size, not by darkness

This is the idea worth understanding, because it explains everything the tool does well and everything it loses.

A photographed page contains two signals mixed together. The illumination varies slowly and broadly: a gradient from the window, a soft falloff towards a corner, the wide dark region under your own shadow. The ink varies quickly and narrowly: a letter stroke is a few pixels wide and goes from paper to full ink and back within that distance.

Brightness cannot tell them apart. A letter in a lit region is far brighter than blank paper in the shadow, which is why thresholding a photographed page produces a black corner and a white corner and nothing useful in between.

Spatial scale can tell them apart, easily. So the operation asks a different question: what would this page look like with the writing removed?

It answers by taking a morphological closing with a thirty one pixel kernel. Closing eliminates dark features smaller than the kernel, so every letter is filled in with the paper tone immediately around it — including that paper's local shading. What comes back is an estimate of your sheet with no ink on it, shadow and all.

Subtract that estimate from the original and the shading cancels, because it is present in both. What remains is only the part that was too small to survive the closing: the text. Invert it, and you have dark writing on clean white paper, with the lighting gone.

What the kernel size decides

The thirty one pixel figure is the one meaningful parameter, and it sets a boundary.

Anything narrower than the kernel is ink. Anything wider is background. That is the whole classification, and it is why the method is so robust for body text — a letter stroke at this working size is a few pixels across, nowhere near the threshold.

It is also why large solid marks vanish. A display heading with thick strokes, a solid black logo, a filled cell in a table, a photograph printed on the page: to the closing these are indistinguishable from a dark patch of paper, so they are absorbed into the background estimate and subtracted away with the shadow.

That is a real limitation and it is not tunable from the page. Documents made of text come out excellently. Documents that are half graphic do not, and it is better to know which of those you have before uploading.

When to use this instead of the AI pages

Most of this site repaints images with a generative model. For a document that is the wrong tool, and it is worth being blunt about why.

A repaint reconstructs the picture, including the characters in it. The model does not read your document; it produces something that looks like a document, and a digit whose shape was ambiguous becomes a confident digit that may not be the one that was printed. Nothing flags it. The result looks cleaner than the original and can be quietly wrong.

For an invoice, a form, a prescription, a meter reading, or anything that will be relied on later, that risk is unacceptable and unnecessary. This page cannot make that mistake, because it has no capacity to generate. Every mark in the output came from a mark in your upload.

Publication gate

This page ships once the workflow has been run against a page with a gradient shadow, a page with a hard shadow edge, a document containing a thick heading and a filled table, and a page of faint pencil writing, with the output compared to the source character by character.

Examples

Page photographed under a desk lamp

page.jpg - 3000x4000, one side of the sheet in shadow
prathom-remove-document-shadows.png - 1224x1632, evenly white

The intended case. A smooth gradient across the sheet is exactly what the background estimate is good at removing.

Page with a hard shadow edge

notes.jpg - 3000x2250, the photographer's shadow across one corner
notes-flat.png - 1632x1224

Also handled, because a hard edge is still large compared to a letter. A faint seam can remain where the shadow boundary crossed the text.

Frequently asked questions

Does an AI model rewrite my document?

No, and that is the reason this page exists in the form it does. The workflow contains no model, no sampler, and no prompt — only arithmetic on the pixels you uploaded. Nothing can invent a character, alter a digit, or produce a plausible word where a smudged one was, because nothing in the chain is capable of generating anything.

Why not just increase the contrast?

Because contrast is a global operation and the problem is local. Raising contrast pushes the shaded region towards black along with the ink in it, and pushes the lit region towards white along with its faint pencil marks. You end up with one part of the page solid and another washed out, which is usually worse than the original.

Why did my heading disappear?

Because the method keeps what is smaller than its kernel and treats everything larger as background. A thick display heading, a solid logo, or a filled table cell can exceed that size and be classified as page rather than as ink. It is a direct consequence of how the separation works rather than a tuning problem.

Will it straighten a page shot at an angle?

No. Nothing here changes geometry — there is no deskew, no perspective correction, and no cropping to the sheet edges. It corrects illumination only. Photograph the page square on, or straighten it in a scanning app first and use this afterwards to fix what the lighting did.

Is the AI Remove Document Shadows tool free, and do I need an account?

Free, and deliberately account-free. Prathom has no login anywhere on the site, so there is no usage counter attached to you and no upgrade prompt waiting at the end of the job. The practical limits are the workflow's own: an image up to 25 MB going in, one queued GPU job at a time, and a result that stays available for thirty minutes.