Key points
- Inpainting works inside a picture: you paint over the spot you want fixed, and the tool fills that spot back in.
- What it fills with comes from the pattern and color around the spot. Anything you didn't paint stays almost as it was.
- You can just erase, or write a sentence telling it what to put there instead.
- The wider the painted spot, the harder the job gets. A small mark disappears cleanly, but a wide gap throws the pattern off.
- Nothing original comes back. Something plausible gets made up in its place.
The analogy
A torn patch of wallpaper doesn't send you re-papering the whole room. You cut out a bit more than the tear, match a new scrap to the same pattern, and press the seam flat until nobody can tell where you worked. Get the trim right and even a close look won't find the spot.
That's what inpainting does. Paint over the spot you want fixed in a photo, and it studies the pattern and color around that spot to fill the middle back in.
The wider the cut, the harder the match gets. One small patch disappears cleanly, but tear out half the wall and the pattern drifts and the seam starts to show, no matter how carefully the new piece gets trimmed.
In detail
Paint the spot to mark it
Open an inpainting tool and a photo comes with a brush. Only the painted area gets rebuilt; everything else stays almost exactly as it was. That painted area is called a mask — like punching a hole in a sheet of paper, laying it over the photo, and only touching what shows through the hole.
The trick is painting a little wider than you think you need. Trace an object's exact outline and you leave its shadow, its reflection on the floor, and the soft blur at its edge behind — enough of a trace that something's clearly missing.
Painting half the frame at once isn't a good idea either. The wider the area to fill, the fewer clues the surroundings give, and the more likely something odd shows up. Big objects come out cleaner erased in two or three passes than one.
It fills by reading what's around it
Filling with an image generator works the same way a new picture gets made. The painted area turns to noise, and each step chips a little of that noise away until a shape appears. The difference is that the untouched area outside the mask stays the reference at every step: it either gets pasted back in from the original, or the model takes the mask and the original together as input. So the inside keeps checking itself against the outside the whole way through.
That's why backgrounds with a clear rule — brick joints, grass, ripples, tile grids — stitch back together beautifully. Backgrounds with no rule, or spots where several objects overlap, are harder to guess from the edges alone, and the results wobble.
You can tell it what to put there
Object-removal tools pave the spot over with background, no sentence needed. That's the move for erasing a passerby or a stray wire from a photo. In a tool that takes a sentence, leaving the field blank can bring in something odd instead of background.
Write a sentence and the story changes. Whatever you describe appears inside the painted spot — a potted plant, a new window, a different shirt color. It still gets shaped to match the light and shadow around it, which is why it reads far more natural than pasting in a cutout from another photo.
Keep the sentence to just what belongs in the painted spot. Describe the whole photo and the tool tries to redraw the surroundings too, and something odd ends up inside your mask. Want one window added? Write "window" and let the surroundings do the rest.
Why the seam shows
When a result looks off, it's usually the border giving it away — the filled spot too smooth, the focus slightly different, the light coming from the wrong direction. Photos shot in low light with a lot of grain make this gap stand out even more.
Repeating patterns are the other giveaway. A floor of tiles or a set of railings has a rhythm your eye already tracks, so if the filled section is off by even one tile, it jumps out immediately. Lining the painted edge up with the grid ahead of time helps a lot here.
The fix is simple: repaint a little wider around the border and run it again. The filled spot and its surroundings get rebuilt together, and the seam melts away. Several smaller passes beat trying to cover a big area in one shot.
More precisely
Inpainting with an image generator rebuilds only what the mask marks. The simplest method pastes the original back over everything outside the mask at every step. A dedicated model trained on mask-plus-surroundings pairs doesn't need the pasting: it builds the inside to match the outside, and blends the border even better. Compressing and decompressing the picture can still shift the outside very slightly, so many tools paste the original outside back at the very end to keep it intact. Some tools add a dial for how hard to rebuild — turn it down and a faint trace of the original shape survives; turn it up and something entirely new takes over. Many dedicated object-removal tools skip the noise and use a model that looks at the surroundings and fills the spot in one pass.
The wallpaper comparison breaks in one spot. A real roll of wallpaper still has matching scraps left to cut, so what you paste really is the same pattern. Inpainting has no idea what used to be there — it invents something plausible with zero knowledge of the original. Something that was merely hidden can vanish and be replaced by something else entirely. And where a wallpaper patch keeps the same material as the rest of the roll, a filled spot can carry a slightly different focus or grain that shows up on close inspection.
Try it yourself
- Cleanup Pictures (erase objects from a photo) ailearn.space Paint over something you want gone and watch how the painted spot blends into what's around it
- Inpaint-web (erase objects from a photo) ailearn.space Try the same photo with a tight paint job and a generous one, and compare how different the results turn out
Common misconceptions
It's easy to think the erased spot comes back to what it originally looked like, but actually a plausible new scene gets built with no regard for whatever was hidden underneath.
It's easy to think painting tight to the outline is the accurate way to do it, but actually you need to cover the shadow and reflection generously too, or a trace gets left behind.
It's easy to think this is the same as background removal, but actually background removal cuts something out, while inpainting fills a gap back in.
One-line summary
Inpainting rebuilds a painted-over spot to match the pattern around it, and the more a big area is touched up in several passes rather than one, the less the seam shows.
Spotted an error or have a better analogy? Suggest an edit · Last updated 2026-10-17