C.W.K.
Stream
Lesson 04 of 10 · published

Inpainting: Editing Part of an Image

~14 min · control, editing, l4

Level 0Spark
0 XP0/100 lessons0/14 achievements
0/200 XP to next level200 XP to go0% complete

Mental model: You've painted a beautiful landscape, but you want to change the sky from blue to a dramatic sunset. Instead of repainting the entire canvas, you tape off everything except the sky, mix your new colors, and paint only within the masked area. The mountains, trees, and lake below stay exactly as they are. That's inpainting — selective editing within a mask while preserving everything outside it.

How Inpainting Works

Inpainting gives you a simple but powerful workflow:

  1. Start with a generated or real image that's mostly right but needs local changes.
  2. Draw a mask over the area you want to change (the "inpaint region").
  3. Write a prompt describing what should appear in the masked area.
  4. Generate: The model fills the masked region with new content while keeping everything outside the mask untouched.
Original Image          Mask                    Inpainted Result
  ┌──────────────┐    ┌──────────────┐        ┌──────────────┐
  │   ☀️ sky     │    │ ████████████ │        │  🌅 sunset   │
  │              │    │ ████████████ │        │              │
  │──────────────│    │──────────────│        │──────────────│
  │  🏔️ mountain │    │              │        │  🏔️ mountain │
  │  🌲 trees    │    │   (keep)     │        │  🌲 trees    │
  │  🏞️ lake     │    │              │        │  🏞️ lake     │
  └──────────────┘    └──────────────┘        └──────────────┘

What Inpainting Excels At

  • Fixing hands: Generated an amazing portrait but the hands have six fingers? Mask the hands, prompt "a natural hand resting on the table," regenerate.
  • Removing unwanted objects: A distracting element appeared? Mask it, prompt the background behind it, let the model reconstruct.
  • Changing clothing or accessories: Swap a jacket for a sweater, add glasses, change hair color — all without regenerating the face.
  • Replacing backgrounds: Keep the subject, mask everything around them, describe a new environment.
  • Fixing text: If text rendered poorly, mask it and either let the model try again or remove it entirely for post-production text addition.

Mask Quality Matters

The precision of your mask directly affects the quality of the inpaint:

  • Too tight: If the mask barely covers the problem area, the model doesn't have enough room to generate a coherent replacement. Include some buffer around the target.
  • Too loose: If the mask covers too much, you lose good parts of the image unnecessarily. Be selective.
  • Feathered edges: Soft mask edges help the new content blend smoothly with the surrounding image. Hard edges can create visible seams.
Key Takeaways
  • Inpainting edits a masked region while preserving everything outside it.
  • Essential for fixing hands, swapping elements, removing objects, and replacing backgrounds.
  • Mask quality matters: include buffer space, use feathered edges, match style in your prompt.
  • The generate → inspect → inpaint loop is the core professional workflow.

External links

Exercise

Generate a portrait with one obvious flaw (e.g., extra finger). Use inpainting to fix it. Document: mask size, prompt for the inpaint, denoising strength, number of attempts. What worked?

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.