Remove Image Noise with a Median Filter

Pick an image and the median filter replaces every pixel with the middle value of its neighbours — isolated dots and dust disappear, edges stay crisp. Nothing is uploaded.

Try:
Denoised image

What a median filter does

A median filter slides a small square window over the image and replaces the centre pixel with the middle value of everything inside that window. Because the middle value is a real pixel from the neighbourhood — not an average — a lone white or black dot has no influence at all: it sorts to the end of the list and is thrown away, while the edge running through the window keeps its two populations of pixels and stays exactly where it was.

That is why median filtering is the standard answer to salt-and-pepper noise (scattered black/white dots from bad sensor pixels, transmission errors or a dusty scan) and why it beats a Gaussian blur, which smears the dot into a grey smudge and softens every edge along with it.

Worked example

Take a 3-pixel-wide row of a photo where one pixel has been hit by noise:

neighbours: 118  120  255  121  119
sorted:     118  119  120  121  255
median:                120

The blown-out 255 is discarded and the pixel becomes 120, matching its neighbours. An average would have produced 146 — a visible bright smudge.

On this page: upload a noisy image, leave Window radius at 1 (a 3×3 window) and press run. Single-pixel dots are gone and the result downloads in the same format you uploaded. Raise the radius to 2 (5×5) for scanner dust or speckle that covers a couple of pixels.

The controls

Limits and edge cases

FAQ

What is the difference between a median filter and a blur?

A blur averages the pixels in the window, so a bright noise dot contaminates every pixel around it and edges soften. A median selects a value that already exists in the window, so an outlier is discarded outright and a straight edge stays straight. For salt-and-pepper noise the median wins clearly; for smooth grain, a blur or a dedicated denoiser is a better fit.

What radius should I use?

Start at 1 (a 3×3 window) — it removes single-pixel dots with almost no loss of detail. Use 2 (5×5) if the specks are 2–3 pixels wide, such as dust on a scan. Above 4 the image starts to look like a watercolour, so if you need that much cleaning, try 2 passes at a small radius instead of one big window.

Why does the result look flat or "painted"?

Because the window is too large for the detail in the image. Every pass replaces texture with the local middle value, so fine grain, skin texture and small type get flattened. Lower the radius, drop to a single pass, or switch Channels to filter to chroma only so luminance detail is left completely untouched.

Can it clean up a scanned document?

Yes — that is the classic use. A radius of 1–2 with dark only removes pepper specks from light paper without eating the strokes of the text, and bright only removes white pinholes from a dark background. Choose PNG output so the cleaned scan is not re-compressed, and tick Strip metadata if you are about to publish it.

Are my images uploaded anywhere?

No. The filter runs in your browser through a WebAssembly build of ffmpeg. The file you pick is read locally, processed locally, and the download link points at the result held in your own tab's memory.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool image-median-denoise 'url=https://example.com/input' 'radius=1' 'target=both' 'channels=all' 'passes=1' 'format=keep' 'quality=92' 'strip_metadata=true'

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/image-median-denoise/?url=https://example.com/input&radius=1&target=both&channels=all&passes=1&format=keep&quality=92&strip_metadata=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.