Inpainting: How do I add an element to an existing image?

Modified on Fri, 1 Nov at 12:38 PM

Inpainting, or adding an inpaint mask, is the primary method for adding elements to an existing image in a way that feels natural and cohesive. 


Conceptually, it’s helpful to understand that inpainting doesn’t simply overlay guidance or text prompts on top of an image; rather, it starts with the existing pixels as a foundation, “remixing” and reworking them to integrate new elements.


A key setting to understand when using inpainting is Denoising Strength. This setting controls the extent to which the model remixes the pixels in the selected area:


  • High Denoising Strength (e.g., 0.8-0.9): This setting will significantly remix the pixels, introducing more variation and potentially adding a lot of new details or changes.
  • Low Denoising Strength (e.g., 0.3-0.5): This setting will remix the pixels less, making only minor changes to the region and keeping it closer to the original base image.


Since inpainting relies on the raster layer’s pixels, it’s important to give the model enough guidance to understand what you are trying to add to the layer. The following sections will guide you through inpainting techniques to add elements and troubleshoot common issues for optimal results.



Adding an Object into an Existing Image

  • Open the Canvas
    • Start by navigating to the Canvas where you’ll work with your base image.
    • Go to the Gallery and drag the image you want to edit onto the canvas.
    • Select New Raster Layer when prompted to set your base image on the canvas.
  • Add an Inpaint Mask
    • Navigate to the Layers tab.
    • Click Add Layer and select Inpaint Mask.
    • Use the Brush Tool (press the B hotkey) or the Rectangle Tool to select the area where you’d like to add the new object. Brush or outline the specific area to create a mask. This is the area that will change when you press Invoke.
  • Copy the Inpaint Mask to Regional Guidance
    • Right-click on the inpaint mask layer.
    • Select Copy Inpaint Mask to: and choose New Regional Guidance to set up guidance for the object you’re adding.
  • Add Your Object via Text Prompt
    • In the Regional Guidance panel, click + Prompt to add a text prompt.
    • Write a description of the object you want to insert, using keywords that describe it accurately.
  • Adjust the Bounding Boxfor Best Results
    • To focus the model’s attention on this specific area, adjust the bounding box to match the size and position of the inpainted region. The model will consider only the area that you define in your bounding box, so a larger bounding box will typically result in a more seamlessly integrated object, but you may sacrifice fidelity on the object itself. You may want to experiment with different bounding box sizes to see how it changes your results.
    • Press the C hotkey or use the bounding box tool from the toolbar to refine the bounding box around the inpainted area. This helps the model deliver detailed results within that confined area.
  • Set the Global Positive Prompt
    • On the left-hand side, set a Global Positive Prompt to describe what is in the bounding box. Include key terms from your regional guidance prompt, ensuring consistency between the prompts.
  • Invoke
    • Press Invoke to generate the new image with the object added in the selected area.



Adding a Significantly Different Object to a Defined Region


When the object you want to add to the image is very different from what currently exists in the selected region, you may need to make a few adjustments to ensure accurate results. Here are two methods to improve the inpainting process:



Method 1: Increase Denoising Strength

  • Adjust Denoising Strength
    • Increase the Denoising Strength to a higher range, around 0.8 to 0.9.
    • This higher denoising strength signals to the model that significant changes are required in this region to align with your prompt. Essentially, this tells the model to replace the current pixels with new content that matches the prompt.


Method 2: Provide Pixel-Based Guidance


If adjusting denoising strength alone doesn’t achieve the desired results, consider adding pixel-based guidance for more control:

  • Method 2A: Create an Additional Raster Layer
    • From the Layers tab, create a New Raster Layer on top of your base image.
    • In this layer, provide the model with rough guidance of the object by sketching or color blocking. This doesn’t need to be highly detailed but should represent the general shape or color scheme of the object. This visual guidance gives the model a starting point for your in-painting prompt.
  • Method 2B: Use an Existing Image Layer
    • If possible, layer an image similar to the object you want to add over the base image. Right click the image and select Transform to resize and position it to fit the region.
    • By transforming this layer to closely resemble your target object, you give the model an even clearer sense of what you’re aiming for.
    • With this approach, adjust the Denoising Strength to a moderate level, around 0.5 to 0.75, depending on how closely the added image resembles your desired object. This range allows for refinement without overpowering the details.




Troubleshooting Common Inpainting Issues

When using inpainting, you may encounter a few common problems. Here are some effective solutions for improving the quality and coherence of your results:


Issue 1: The Inpainted Object Isn’t Blending with the Background

If the added object doesn’t blend naturally with the surrounding background, follow these steps to adjust blending settings:

  • Navigate to Compositing Settingson your left sidebar of the canvas
    • Under the Compositing module you’ll find Coherence Pass and Infill settings, explore different methods for blending the in-painted region.
    • These compositing options offer multiple ways to help the new object blend seamlessly with the base image.
  • Experiment with Infill Methods
    • Try different infill methods, which vary in how they merge the inpainted pixels with the surrounding pixels. Testing multiple options can help you achieve a more natural result.


Issue 2: Unintended Objects or Elements in the Inpainted Region

Sometimes, you may see strange or unrelated elements in the inpainted area that weren’t included in your prompt. This issue often arises when a term in the global prompt doesn’t have a clear place in the composition, leading the model to insert it in the inpainted area.


To resolve this:

  • Expand the Bounding Box
    • Increase the bounding box size around the inpainted region. This gives the model more area to work with, reducing the chance of misplaced elements.
  • Adjust the Global Prompt
  • Review your Global Positive Prompt for terms that may be adding unintended elements to the in-painted region.
  • Remove or refine any terms that could confuse the model’s interpretation of the area. Streamlining the global prompt often results in cleaner, more accurate inpainting.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article