Black October, explainedAppsGuidesAI DictionarySmall FixesOn RecordAboutFollow the lab

Inpainting

Also called generative fill, outpainting, magic eraser

Inpainting is AI that fills in a part of a picture you mark, so it matches everything around it: removing a stranger, or adding something new.

In plain words

You take a lovely photo at the beach, and a stranger walks right through it. With inpainting, you brush over the stranger, and the AI paints sand and sea where they stood.

The area you brush over is called a mask. Everything outside the mask stays as it was. Inside, the AI invents new pixels that fit the light, colours and lines around the hole.

You can also type what should go there, like "a red umbrella". Filling beyond the edges of a photo, to make it wider or taller, is called outpainting. Phone features with names like magic eraser and photo-editing tools with generative fill both work this way.

Everyday example

Darning a hole in a sweater

A good darner looks at the knit around a hole, the colour and the pattern, and weaves new yarn that continues it. The rest of the sweater is left alone. Inpainting does the same with pixels: it studies what surrounds the masked area and weaves in new picture that continues it.

Where the example breaks: The darner restores what was there. Inpainting cannot know what was really behind the stranger. It paints what is likely, which may look right but never existed, so an inpainted photo is no longer a record of what happened.

Go deeper

How it actually works

The word comes from art restoration, where restorers fill in damaged parts of a painting. Early digital inpainting copied nearby patches. Today it is mostly done with generative models.

  1. You mark a mask

    The mask is a second, black and white image the same size as the photo. White means "fill this in", black means "keep this". A brush, a lasso, or an automatic segmentation tool that outlines the object for you can make it.

  2. The masked area is hidden under noise

    In a diffusion model, the masked area is filled with random noise, while the rest of the picture is kept as a guide.

  3. Denoise only inside the mask

    Step by step, the model removes noise from the hole. At every step it looks at the untouched pixels around it, so lighting, shadows and edges line up. If you typed a prompt, the words steer what appears.

  4. Blend the edges

    The new patch is blended into the original along the mask's edge so no seam shows. Outpainting is the same idea with the mask outside the old borders: the canvas is extended and the empty space treated as the hole.

Digital inpainting
2000: a SIGGRAPH paper by Bertalmio, Sapiro, Caselles and Ballester copied the methods of professional restorers
On phones
October 2021: Google's Magic Eraser on the Pixel 6 used machine learning to predict the pixels behind removed distractions
In photo editors
May 2023: Adobe added Generative Fill to Photoshop, adding, extending or removing content with text prompts
Uses
Removing objects, repairing old or torn photos, replacing a sky, trying products in a room, extending a photo to a new shape

Because inpainting can quietly change what a photo shows, some tools attach Content Credentials that record an image was AI-edited.

Questions people ask

What is the difference between inpainting and outpainting?

Inpainting fills a hole inside the picture, like removing a person. Outpainting extends the picture beyond its edges, like turning a tall photo into a wide one. Both use the same trick: the AI invents pixels that match what is already there.

How does magic eraser know what was behind the object?

It does not know. It predicts what is likely to be there from the surroundings and from many pictures it learned from. Plain backgrounds like sky or sand come out convincingly. Busy scenes, faces or text behind the object often come out blurry or wrong.

Is inpainting the same as image-to-image?

They are close cousins. Image-to-image redraws the whole picture. Inpainting redraws only the masked part and keeps the rest of the picture as it was, which is why it suits small fixes.

Can an inpainted photo be used as proof?

Be careful. An inpainted photo shows something invented by the AI, not what the camera saw. Some apps record AI edits in the file's Content Credentials, so the change can be traced. Using an edited photo to fake or hide evidence can be illegal.

Further reading