Generated Images, Video and Voice
Inpainting and Outpainting: Editing Part of a Picture With AI
How AI tools fill a selected area or extend a picture past its edges, how to get clean results, and when an edit becomes deception.
Key takeaways
- A mask tells the tool which pixels it may change, and the rest serves as context.
- Selecting a little beyond the object, including its shadow and reflection, usually gives a cleaner fill.
- Work in several small passes and zoom in to check edges, texture, perspective and lighting.
- Outpainting suits changing a picture's shape, but each extension drifts further from anything real.
- Keep the original, and disclose edits that change what a viewer would believe.
Inpainting regenerates a region you select inside a picture, and outpainting invents new picture beyond its original borders. In both, the AI looks at the surrounding pixels and often your written instruction, then produces content that fits. It can remove a stray cable, swap a mug for a vase or turn a square photo into a wide banner.
The filled area is invented. The tool has no knowledge of what was really behind the object you erased or what lay outside the camera's view.
The basic idea of a mask
To edit part of an image you mark it, usually by brushing over it or drawing around it. This marked area is the mask. Inside it the model may generate new content. Outside it the picture should stay as it was.
Many inpainting systems build on the same noise-removal method used to create images from scratch, described in how image generators work. Noise is introduced where the mask is, and the model resolves it step by step while the surrounding pixels constrain the answer.
Some chat-style tools skip the brush: you type "remove the person on the left" and the system works out the region itself. That is convenient, but check the whole picture afterward, because areas you never mentioned may be redrawn too.
Removing, replacing and adding
The three common jobs behave differently.
| Job | What to tell the tool | Typical difficulty |
|---|---|---|
| Remove an object | Often nothing, or "plain background" | Leftover shadows; repeating textures |
| Replace an object | Describe the new item, its color and material | Scale and lighting mismatch |
| Add something | Mask an empty spot with room to fit, then describe | Floating objects without contact shadows |
| Change clothing or color | Describe the change only | Altered face or hands nearby |
When removing, a text instruction naming the unwanted thing can backfire: writing "remove the dog" into a prompt box that expects a description may produce another dog. If the box describes what should appear, describe the background you want.
Getting a clean result
Most poor edits trace to the mask. Follow this sequence.
Large removals are harder than small ones because there is less nearby evidence. Break them into pieces: first the lower half of the object against the floor, then the upper half against the wall. Straight lines such as shelves, tile grout and horizons often bend or fail to meet across a filled patch, so inspect them closely.
Texture is another giveaway. A filled area may be smoother, sharper or less grainy than the rest. Some editors offer tools to add matching grain or soften the join.
Extending the frame with outpainting
Outpainting is useful when the shape is wrong: you have a vertical portrait and need a horizontal slide, or you want breathing room around a product.
Extend in modest increments. Each new strip is based partly on the previous one, so small inventions compound. A beach may sprout a second sun, a room may gain impossible architecture, and repeated elements may march off toward the edge.
Give a brief description of what continues: "same plain gray wall and wooden floor". Quiet backgrounds extend convincingly. Busy ones with crowds, text or machinery do not. If the subject is cut off at the edge, the model will guess at the missing arm or wheel, and the guess deserves a careful look.
Resolution also matters. Filled regions in very large images are often generated at a smaller size and then scaled, which can leave them softer than the original.
Matching light, scale and perspective
A new object has to obey the picture it joins. Look first at the light: which side is bright, how soft the shadows are and whether the color is warm or cool. Mention these in your instruction when the first attempts miss, as in "lit from the right by soft window light".
Then check scale. Compare the addition with something of known size nearby, such as a door handle or a cup. Models sometimes produce a lamp as tall as a person.
Perspective is the way shapes and parallel lines appear to shrink and converge with distance. A table seen from above will look wrong in a room photographed from eye level. A roomy mask lets the model place a contact shadow and angle the object correctly, while a tight mask forces it into whatever outline you drew. Mask a shape roughly like the thing you want, with space beneath it for the shadow.
Keeping track of versions
Repeated editing can degrade an image, especially if each pass saves in a lossy compressed format. Edit from a high quality copy, save intermediate versions with short names, and keep a note of what changed in each. If a later step goes wrong, you can return to a clean point.
Layers in an image editor help here. Placing each generated patch on its own layer lets you hide, resize or erase parts of it without redoing the whole picture.
Where it works well and where it struggles
For text, erase the faulty lettering with the tool and typeset the words yourself. For hands, mask the entire hand and wrist, not a single finger, so the model can build a coherent shape. The reasons are explored in why hands and text go wrong.
Restoration is reconstruction
Inpainting can repair scratches and tears in a scan of an old family photograph. The result can be lovely, and it is still a guess. A damaged eye rebuilt by a model may not look like your grandmother's.
Scan at high quality first, keep that scan untouched, and label repaired copies. The same tension, at larger scale, appears in restoring and colorizing old footage.
A hypothetical example
Say you have a vertical photo of a handmade bowl on a wooden table and need a wide banner for a craft fair listing. A bright cable also pokes into the lower corner.
First you copy the file. You mask the cable together with its shadow, describe "bare wooden tabletop" and generate a few versions, choosing the one whose grain lines up with the real boards. Next you extend the canvas to the left in two modest steps, asking for the same table and a plain wall. In one attempt a second, invented bowl appears, so you discard it.
Finally you compare the bowl itself with the original to confirm that no pass has changed its shape, glaze or chips. A buyer is judging that object. The wider table is background, and a short note that it was extended costs you nothing.
When another method is better
Generation is not always the right tool. Reshooting the photo often takes less time than repairing it, and leaves you with a true record. Cropping solves many distractions with no invention at all. For a plain studio backdrop, a simple color fill is predictable and repeatable.
When the missing content must be exact, such as a product label, a map or a name badge, go back to a source file and place it with ordinary design tools. A model can only offer something that resembles it.
Honesty and consent
Editing part of a photo is often harmless: tidying a vacation shot, removing dust, widening a banner. It crosses a line when it changes a fact someone relies on.
- Do not remove damage from items for sale or add features a property lacks.
- Do not alter documents, receipts, medical images or photos used as evidence.
- Do not put people into places or situations they were not in without their agreement.
- Never create sexual or humiliating edits of anyone. This causes serious harm and is illegal in many places.
Some tools attach metadata or watermarks marking AI edits. These can be lost, so do not rely on them to carry your disclosure. A plain caption such as "background extended with AI" is clearer. Phone-based editing raises the same questions, discussed in AI photo editing on your phone.
Privacy of the picture you upload
Editing usually means sending the photo to a company's servers, though some features run on the device. A picture can reveal faces, home interiors, license plates, documents on a desk and location data stored in the file.
Before uploading, crop out what the edit does not need, strip location information if you can, and read the current terms on storage and use for training. For work images, follow your employer's rules about approved tools. Do not upload photos of other people's children without permission.
Common questions
Is inpainting the same as a clone stamp?
A clone stamp copies pixels you choose from elsewhere in the image. Inpainting generates new pixels. Cloning is more predictable and transparent about its source, while generation handles larger gaps.
Can the tool recover what was behind an object?
No. If a person stood in front of a sign, the filled sign is a plausible invention. Only another photograph of the same spot can show what was there.
Why did areas outside my mask change?
Some systems regenerate the whole image and blend, especially in conversational editors. Compare against the original, and paste back untouched areas in an image editor if precision matters.