Inpainting and Outpainting
Inpainting fills in or replaces a masked region inside an image, while outpainting extends an image beyond its original borders.
Overview
Together they let you erase objects, fix flaws, and expand scenes seamlessly using generative AI.
Deep Dive
Inpainting and outpainting are masked-region image editing tasks. With inpainting, you paint a mask over part of a photo—say, an unwanted tourist or a scratch—and the model regenerates only that area to match the surrounding content. Outpainting does the reverse: it treats the area *outside* the original frame as the region to fill, inventing plausible new scenery so a portrait becomes a full landscape. Diffusion models excel here because they generate by denoising and can be conditioned to keep unmasked pixels fixed while synthesizing the masked ones, optionally guided by a text prompt. The result blends in lighting, texture, and perspective so edits look native. These tools power everyday features like 'magic eraser' on phones and 'generative expand' in pro editors.
Technical Insight
In diffusion-based inpainting, the masked area starts as noise and is progressively denoised, while at each step the known (unmasked) pixels are re-injected so the model only 'paints' inside the mask. A text prompt can steer what appears. Outpainting reuses the same machinery by extending the canvas, masking the new blank border, and conditioning on the existing edge content so colors, lighting, and perspective continue naturally beyond the original frame.
Strategic Impact
Speed and scale
Visual AI can automate inspection, detection, and tagging tasks at scale.
Build choices
Creative teams can prototype concepts faster with fewer manual revisions.
Team and workflow
Operations can use image and video signals that were previously hard to process.
The Future of Inpainting and Outpainting
Editing is getting faster, higher-resolution, and more controllable. Expect prompt-driven edits ('remove the car, add a bench') to become reliable one-click actions, with better preservation of fine textures, reflections, and shadows. Outpainting will routinely reframe and re-aspect-ratio photos and video frames for different screens. The same techniques are moving into video—removing or extending content across frames consistently—raising both creative possibilities and concerns about undetectable photo manipulation and the need for provenance tags.
Real-World Implementation
Erasing a photobomber from a vacation photo so the background fills in naturally.
Expanding a vertical portrait into a wide banner by generating new scenery on the sides.
Removing wires, blemishes, or logos from product shots for clean catalog images.
Restoring old or torn photographs by reconstructing missing or damaged regions.
Risks & Guardrails
Image rights and consent can become legal risks if provenance is unclear.
Model performance can vary across lighting, demographics, and environments.
False positives may go unnoticed unless confidence thresholds are monitored.
Implementation Roadmap
Define acceptance criteria for precision, recall, and error costs.
Test with data that matches real production conditions.
Add human review for low-confidence or high-impact predictions.
Track model drift and revalidate after camera or dataset changes.
Keep Exploring
Free newsletter
Keep up with AI in 3 minutes a day
One short email each weekday with the three AI stories that actually matter. Free forever, no ads.
One email each weekday. Unsubscribe in one click. We never sell or share your address.
Test yourself
Take the Inpainting and Outpainting quiz
Instant feedback on every answer, and a shareable certificate with a verifiable ID once you pass a course.
Support free AI education. AI Understanding is a 501(c)(3) nonprofit — no ads, no paywall, ever. Make a donation
Next guide
LaMa Resolution-Robust Inpainting
Frequently asked questions
What is Inpainting and Outpainting?
Inpainting fills in or replaces a masked region inside an image, while outpainting extends an image beyond its original borders. Together they let you erase objects, fix flaws, and expand scenes seamlessly using generative AI.
What does inpainting do?
Inpainting fills or replaces a selected region inside the existing image to match its surroundings.
What does outpainting do?
Outpainting extends the canvas, inventing plausible scenery outside the original frame.
In diffusion-based inpainting, what happens to the unmasked pixels during generation?
Known pixels are re-injected at each denoising step so the model only synthesizes the masked area.
Which everyday phone feature is a form of inpainting?
'Magic eraser' tools remove an object and inpaint the background to fill the gap.
What guides the content that appears in a masked region?
Models condition on neighboring pixels and an optional text prompt to decide what to generate.