Addaly is in open beta. Things will change, and AI answers can be wrong — check anything that matters.

Making Things With AI

Images, video, voice and music — how they work, where they break, who owns them.

Lesson 31 of 848 min

Masks, feathering and the context window

What a mask actually does

Inpainting is the same denoising loop with one addition. At every step, the parts of the latent outside your mask are overwritten with the correctly-noised version of the original image. Only the inside of the mask is free to change.

That means the region being regenerated is surrounded, at every step, by the real picture. The model is not repairing in isolation; it is completing a scene it can see. This is why inpainting produces results that match lighting and colour without being told to, and why it is a different and far more reliable tool than regenerating the whole image and hoping.

The three settings that decide the result

Mask size and shape. Too tight and the model has no room to place anything; the fix is squeezed into an area the wrong shape. Too loose and you have thrown away good pixels. A useful default is to mask the problem plus roughly half its own width of surrounding area.

Feather or blur. A hard-edged mask leaves a visible seam because the boundary between generated and original falls on a single pixel line. A feather of 4 to 16 pixels blends the transition. This one setting is the difference between a repair that reads and one that announces itself.

Context area — the setting nobody explains. Most implementations do not process the whole image for an inpaint. They crop a region around the mask, scale it to the model's native size, generate, and paste back. The size of that crop is the model's entire view of the scene.

This last one explains the most common inpainting failure. Mask a face in a large image with a tight context crop, and the model sees a face-sized rectangle with no shoulders, no horizon and no light source. It has no idea which way the light falls, so it invents one. Widen the context and the same mask produces a correct result. In WebUI this appears as "only masked padding"; in ComfyUI it is the crop size on the inpaint node. When a repair comes back lit wrong, this is nearly always why.

One inpaint, and where the extra detail comes fromMask theproblem, plushalf its ownwidthA tight maskleaves no roomto placeanything. Afeather of fourto sixteenpixels stops theboundary landingon a single lineof pixels andannouncingitself.Crop a contextarea around itThis crop is themodel's entireview of thescene. Too tightand it cannotsee the lightsource, so itinvents one —which is why arepair comesback lit wrong.Scale the cropup to themodel's nativesizeA face worthseven latentcells in thewhole picturenow gets thewhole grid. Itis not tryingharder; it hassixteen timesthe cells.Denoise, withthe outsideoverwrittenevery stepOnly the insideof the mask isfree to change.The surroundingreal pixelscondition it atevery step,which is whycolour andlighting matchwithout beingdescribed.Scale back andblendThe repair ispasted into theoriginal throughthe featherededge.Outpainting is the same machinery pointed outwards: pad the canvas, mask the new area, and extend insteps of 128 or 256 pixels so each step still has context to hold on to.
One inpaint, and where the extra detailcomes fromMask the problem, plus half its own widthA tight mask leaves no room to place anything. Afeather of four to sixteen pixels stops theboundary landing on a single line of pixels andannouncing itself.Crop a context area around itThis crop is the model's entire view of thescene. Too tight and it cannot see the lightsource, so it invents one — which is why arepair comes back lit wrong.Scale the crop up to the model's native sizeA face worth seven latent cells in the wholepicture now gets the whole grid. It is nottrying harder; it has sixteen times the cells.Denoise, with the outside overwritten everystepOnly the inside of the mask is free to change.The surrounding real pixels condition it atevery step, which is why colour and lightingmatch without being described.Scale back and blendThe repair is pasted into the original throughthe feathered edge.Outpainting is the same machinery pointed outwards:pad the canvas, mask the new area, and extend insteps of 128 or 256 pixels so each step still hascontext to hold on to.

Why the crop is also a resolution gift

There is a bonus in the crop mechanism worth exploiting deliberately. Because the cropped region is scaled up to the model's native size before generation, a small masked area is being generated at full model resolution and then scaled back down.

A face that occupies seven latent cells in the full image occupies the whole latent grid when inpainted with a tight crop. This is the mechanism behind face-detailer workflows, and it is why inpainting a small element gives dramatically more detail than the same element in the original generation. It is not that the model tries harder. It has sixteen times the cells.

Outpainting is the same thing pointed outwards

Extending an image beyond its borders uses identical machinery: pad the canvas, mask the new area, inpaint with the existing image as context. The failure modes are the same. Extend too far in one pass and the far edge has no context and drifts; extend in steps of 128 or 256 pixels and each step stays anchored.

A practical note that saves a lot of confusion: many models are markedly worse at outpainting downward than in other directions, because photographs are cropped at the bottom far more consistently than at the top, so the training data contains fewer examples of what continues below a frame.

Where inpainting stops being the answer

Inpainting is the right tool for a wrong region. It is the wrong tool for a wrong picture. If the composition is not working, no amount of masked repair will fix it, and you will spend an hour discovering that.

There is also a class of problem inpainting handles badly: anything requiring agreement with a region you are not regenerating. Fixing one earring to match the other means the model must reproduce the other, which it can only see as context. It often gets close and rarely gets exact. For symmetry, the reliable fix is mechanical — copy the good one, flip it, place it, blend — in GIMP, Krita or Photopea, all free.

The general rule that emerges across this module: use the generative tool for texture and content, and use ordinary image editing for geometry and symmetry. Each is far better than the other at its own job, and most of the frustration people report comes from asking one to do the other's work.

The one thing to keep

Masked regeneration replaces only the masked latent while conditioning on the surrounding pixels, so what the model can see around the mask determines whether the repair matches.

Before you move on

An inpainted face comes back correctly rendered but lit from the wrong side. Which setting is the first thing to change?

Pick the one you would defend. Nobody sees your answer.

No ads. No data sale. No public scores on people. Ever.

© 2026 Addaly