How AI Image Editing Tools Work: Inpainting and Outpainting

A photo editor removing an object from a landscape photo on screen

How AI Image Editing Tools Work: Inpainting and Outpainting

A photo editor removing an object from a landscape photo on screen

Modern AI image editing tools can remove a stranger from your photo, replace a grey sky with a sunset, or extend a portrait into a wide landscape, all from a few words.

The magic looks effortless, but it runs on a precise mechanism: a diffusion model that rebuilds only the pixels you mark, while the rest of the image stays untouched.

The short answer is that inpainting regenerates a masked region of an image while conditioning on the surroundings, and outpainting is the same process applied past the image’s edges. Both use a diffusion model that starts from noise and cleans it up step by step, guided by your prompt.

If you searched for how ai image editing tools work inpainting and outpainting explained, this guide answers it in plain language, with the mechanics, the tools and the settings that matter. It covers the 9-channel inpainting model, masks, denoise strength, and why edits sometimes go wrong.

Key Takeaways

  • Inpainting regenerates a masked region while the rest of the image stays untouched; outpainting extends the image past its borders.
  • A dedicated inpainting model takes nine input channels: noisy latent, encoded image and mask, instead of the usual four.
  • The mask decides where change is allowed, and denoise strength decides how much change is allowed.
  • Mask-based editing and instruction-based editing are different mechanisms, and using the wrong prompt style on the wrong tool does nothing.
  • Outpainting works best in small steps: extend a little, accept the result, then extend again.

Close-up of a mask selection around an object in a photo editing app
What Inpainting and Outpainting Actually Are

Inpainting fills a chosen area of a picture with something new, keeping the rest untouched. A client sends a perfect product photo with a distracting sign in the background, and inpainting replaces the sign with clean background.

The good repair is not the one with the nicest patch; it is the one you cannot find afterwards.

Outpainting is the same craft applied at the edges. You have a photo that was cropped too tight, and you want more sky above and more road below. Pad the picture with blank space, mark all the blank space as repaintable, and run inpainting. That is genuinely all outpainting is.

Image editing is a third, broader family. It regenerates the whole image but keeps semantic or structural fidelity to the original, using techniques such as SDEdit and InstructPix2Pix. Inpainting changes a region, outpainting changes the borders, and image-to-image changes the whole picture by a chosen amount.

How a Diffusion Model Edits an Image

A text-to-image run starts from pure noise and is not committed to any pixel. An edit starts from a real image, and most of it should survive.

Every mask-based technique reduces to the same three operations: encode the image to latents with the VAE, add a controlled amount of noise, optionally only inside a mask, and denoise back to a clean latent under a new prompt.

The mechanism that keeps the rest of the picture safe is neater than most people expect. At every single denoising step, the model’s work outside the mask is thrown away and replaced with the real photo, degraded to match that step’s noise level.

The known part of the image is re-asserted hundreds of times, so it cannot drift.

But the model does see the known part every round. Its guesses inside the hole are shaped by what surrounds them, which is why the fill matches the lighting, perspective and texture around it. The model was looking at the surroundings the whole way, so the new content blends instead of clashing.

A wide landscape photo extended beyond its original borders
The 9-Channel Inpainting Model, in Plain Language

The naive way to inpaint is to run a standard text-to-image model with a mask, replacing the unmasked region of the noisy latent at each step. It works badly: boundary artefacts bleed through, because the model has no information about what is in the masked region.

The proper inpainting model trains a modified network that takes nine input channels instead of four: the noisy latent, a copy of the VAE-encoded source image, and a single-channel mask.

At training time, the model is shown randomly masked regions and trained to denoise only the masked region, while the unmasked region is given as a clean conditioning signal.

SD-Inpaint, SDXL-Inpaint and FLUX.1 Fill all use this nine-channel input or an equivalent. In the popular Diffusers library, the pipelines are called StableDiffusionInpaintPipeline and FluxFillPipeline. The extra channels are the reason dedicated inpainting models blend far better than a general model with a mask bolted on.

Masks: The Stencil That Decides Everything

A mask is a single-channel image. White means regenerate, black means keep, and grey means partial change, which only differential diffusion honours. You supply two things: the picture, and a mask marking which pixels may change.

How you make the mask matters as much as the model. A tight mask around an object leaves the model no room to blend, which creates visible seams. A slightly loose mask, with a soft feathered edge, gives the model space to match the surroundings.

Meta’s Segment Anything model, known as SAM, plus a diffusion inpainting model is the standard 2026 pipeline for background removal.

Some 2026 tools do not use a mask at all. Google’s Gemini image models use semantic masking, where the instruction itself is the mask. Black Forest Labs’ FLUX.1 Kontext and FLUX.2 edit models read a plain-language instruction and decide which regions to touch.

Using a masked-inpainting prompt on a tool that reads only instructions does nothing.

Denoise Strength: Why Edits Go Wrong

Denoise strength is a number between zero and one that sets the noise level the edit starts from. A diffusion sampler walks a noise schedule from high noise to none, and an edit skips the top of the schedule, injecting the encoded image partway down at the level that corresponds to the strength.

Low strength keeps the edit close to the original: the change is subtle, but a stubborn object may survive. High strength gives the model freedom to invent, but the result can drift away from the original image.

The classic failure is setting strength too low to remove an object, then too high and watching the whole scene change.

Two parameters decide every edit: where change is allowed, which is the mask, and how much change is allowed, which is denoise strength. Instruction editors hide both, letting the model decide. That is convenient, but it is also why instruction edits sometimes change things you did not ask about.

TechniqueWhat changesSource of new contentTypical use
InpaintingMasked region onlyModel, conditioned on surroundingsReplace, remove or repair an object
OutpaintingNew canvas past the bordersModel, conditioned on the edgeExtend a scene, change aspect ratio
Image-to-imageWhole image, by a set amountThe re-noised originalRestyle, refine, sketch to render
Instruction editingWhatever the instruction impliesEdit model reading the imageAttribute, object and style edits
SDEditWhole image, from a noise levelRe-noised original under new promptFree-form editing without training

Mask-Based vs Instruction-Based Editing in 2026 Tools

In 2026, editing tools split across three mechanisms. Mask-based dedicated endpoints, such as Stability’s inpainting API and FLUX.1 Fill, take an image, a mask and a prompt. Conversational editors, such as Google’s Gemini image models and Midjourney’s Edit Model, take only an instruction. Canvas-expand tools take pixel offsets for outpainting.

FLUX.1 Fill, released by Black Forest Labs on 1 November 2024, is the reference dedicated model. Its dev variant has about 12 billion parameters, is guidance-distilled, and its Diffusers example uses a guidance scale of 30 and 50 steps. It supports both filling inside the image and extending beyond the edge.

The older techniques still matter. SDEdit, from Meng and colleagues in 2022, adds noise to the source image up to an intermediate level, then runs the reverse chain with a new prompt. InstructPix2Pix, from Brooks and colleagues in 2023, fine-tunes a model on triples of input image, instruction and output image.

RePaint, from Lugmayr and colleagues in 2022, resamples during the reverse process to improve the fill.

Editing Framework: A Reliable Workflow for Clean Edits

Use this framework for any inpainting or outpainting job, whether you use a dedicated model or a conversational editor.

  1. Start from the highest-quality source image you have, because edits cannot add detail that was never there.
  2. Draw the mask slightly larger than the object, with a soft feathered edge for blending.
  3. Describe what should appear in the masked area, not what should disappear.
  4. Set denoise strength in the middle first, then adjust up or down based on the result.
  5. Check the seams at full zoom before accepting an edit, especially on skin and text.
  6. For outpainting, extend a little at a time and accept each step before extending further.
  7. Keep the original file untouched, and save each edit as a new version.

Frequently Asked Questions

What is inpainting in AI image editing?

Inpainting regenerates a masked region of an image while keeping the rest untouched. You supply the image, a black-and-white mask marking what may change, and a prompt describing what should appear there. Dedicated models such as FLUX.1 Fill and SDXL-Inpaint are trained specifically for this job.

What is the difference between inpainting and outpainting?

Inpainting fills a chosen area inside the image’s existing frame, while outpainting adds pixels beyond it. Mechanically they are the same process: outpainting pads the image with blank space, marks the blank space as repaintable, and runs inpainting on it.

How does the 9-channel inpainting model work?

A dedicated inpainting model takes nine input channels: four for the noisy latent, four for the VAE-encoded source image, and one for the mask. The extra channels give the model the unmasked image as a clean conditioning signal, so the fill matches the lighting, perspective and style of the surroundings.

What is denoise strength and why does it matter?

Denoise strength, from zero to one, sets the noise level an edit starts from. Low strength keeps the result close to the original, while high strength gives the model more freedom to invent. Too low and the object survives; too high and the whole scene can drift.

It is the setting that most often explains a failed edit.

Can I edit an image without drawing a mask?

Yes, with instruction-based editors such as FLUX.1 Kontext, FLUX.2 and Google’s Gemini image models. You write a plain-language instruction such as make the jacket red, and the model decides which regions to touch. These tools are convenient, but they give you less control than a mask.

Why do my AI edits have visible seams or colour shifts?

Seams usually come from a mask that is too tight or too sharp, leaving the model no room to blend.

Colour shifts can come from denoise strength set too high, or from the model’s own limitations: the FLUX.1 Fill model card notes slight colour shifts in unfilled areas and possible lines at the edges of filled areas on complex textures.

Conclusion

AI image editing works by rebuilding only what you mark, while the rest of the image is re-asserted at every step so it cannot drift. Inpainting fills a masked region, outpainting extends the canvas, and the two controls that decide every result are the mask and denoise strength.

Choose the right mechanism for your tool, and extend in small steps.

To go deeper, read our guides to how AI image generators work, what multimodal AI is and why it matters, how to write better AI prompts and how AI chatbots work. The model does the painting, but the mask and the prompt are yours.

on this page