Diffusion · 5 Interactives

Repaint the Hole Without Touching the Wall

Inpainting sounds like magic: erase one thing from a picture and the model paints something plausible in its place. The mechanism is a single trick — at every denoising step, everything outside your mask is forcibly reset to the original image, so only the hole is free to change. Below you'll run that trick, paint your own masks, and then break it in the three ways it always breaks.

The paste-back trick Paint your own mask Too tight Too much Seams & feathering
EP 01

The paste-back trick — why the rest of the picture can't drift

The whole image gets noised and denoised — but after every step, the pixels outside the mask are overwritten with a re-noised copy of the original. Only the hole keeps whatever the model dreamed. Your job: remove the moon from this night scene (dashed region). Run it correctly, then run it with the paste-back turned off and watch the "untouched" parts of the photo mutate into a different scene.

30-step denoise · dashed = mask

Both runs use the exact same denoising loop — the only difference is whether known pixels get pasted back each step.

Why it matters: a diffusion model has no "edit" mode — it only knows how to generate whole images from noise. Inpainting in Stable Diffusion, Photoshop Generative Fill and DALL·E works by clamping the known region at every one of the ~30 steps. Skip the clamp once and the picture you loved quietly becomes a picture you never took.
EP 02

Paint a mask, erase a star — context fills the hole

Now you hold the brush. Drag on the image to paint a mask over anything — a star, the moon, a chunk of hillside — then hit Regenerate. The fill is computed from the pixels at the mask's border: the sky continues, the ridge line continues, gradients flow inward. That's the good case: a mask surrounded by rich context gets a seamless, boring, correct fill.

masked: 0.0% of the image

Conceptual simulator — no trained model runs in this page. The fill diffuses in from the mask's boundary pixels, which is exactly the role surrounding context plays for a real inpainting U-Net.

The mental model: the model never "sees the object you erased" — it only sees a hole plus everything around it, and asks "what would plausibly live here?" Good inpainting is context continuation, not object memory. This is why removing a person from a lawn works great: lawns are easy to continue.
EP 03

The too-tight mask — nothing coherent fits in there

The #1 beginner mistake: masking the old object pixel-perfectly. A bird sits in this sky; you want a balloon there instead. But a balloon is a different shape — if the mask hugs the bird's silhouette, the balloon must be squeezed into bird-shaped pixels, and the bird's soft edge pixels just outside the mask survive as a dark fringe. Slide the padding and regenerate at each setting.

balloon fit: —leftover bird pixels: —

Padding 0 means the mask is exactly the bird's core silhouette. The balloon needs room the mask doesn't grant.

Rule of thumb: mask the region where the new thing should live, not the outline of the old thing. Every inpainting UI tells you to "expand the mask a bit" — this is why. A cramped mask gives the model no room for a coherent object, and un-masked halo pixels of the old object leak into the result.
EP 04

Mask too much and the model invents a different world

The opposite failure: the fill is anchored by border pixels, and border shrinks relative to area as the mask grows. Mask 30% of the frame and the night sky continues politely. Mask 90% and the surviving sliver can't outvote the model's prior — it hallucinates a completely unrelated scene (here: a sunny desert) that ignores the strip of night still visible at the edges. Drag coverage up and regenerate.

usable context: —prior takeover: —

"Prior takeover" is the simulator's actual blend weight between context-driven fill and the model's imagination — computed from how little border survives.

Why it matters: past a certain mask size, "inpainting" is just text-to-image generation with a decorative border. Real users hit this constantly — mask a whole person against a wall and get a bookshelf, a window, a stranger. If you want the scene respected, leave the model enough scene to respect.
EP 05

The seam problem — hard edges betray the patch

Even a good fill is never a perfect color match — the regenerated patch here came back a touch brighter and warmer, which is typical. With a hard-edged mask that mismatch becomes a visible cliff at the boundary. Feathering fades the patch into the original over a few pixels, spreading the mismatch until your eye can't find the edge. Drag the slider and watch the measured seam contrast fall.

seam contrast: —

Seam contrast = average color jump measured across every pixel pair straddling the mask boundary, live from the composite you see.

The honest fine print: feathering hides the edge, not the mismatch — the patch is still slightly brighter, your eye just stops finding a line to blame. Real pipelines do exactly this (mask blur / soft inpainting), plus color-harmonize the patch. When you see a ghostly rectangle around an AI edit, someone skipped this episode.
Keep playing
Generative Models
img2img & Strength
How much of your image survives the noise?
Generative Models
ControlNet
Draw a skeleton the image must obey