> For the complete documentation index, see [llms.txt](https://sogni.gitbook.io/sogni-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sogni.gitbook.io/sogni-docs/sogni-studio/creating-images/other-tools/masks.md).

# Masks

Use this tool to create masks from your images. A mask has clear areas that can be filled or replaced — ideal for removing objects, changing backgrounds, replacing subjects, and more.

A mask is an image with clear areas, when used with [Kontext](/sogni-docs/sogni-studio/creating-images/generation-settings/context-editing-and-mixing/context-fill.md) or the InPaint ControlNet model, the generation process will focus on filling the clear areas of the image. This is a really powerful solution when you wish to remove objects from an image, change background, subjects, faces, etc.

The tool works as a "lasso" tool. Simply outline the area you wish to mask.

#### Options :&#x20;

**Reset:** Removes all drawn areas and restores the original image state.\
\
**Invert:** Inverts the selected areas. For example: if you cleared the subject of the image, you can use the Invert button to clear the background instead.\
\
**Apply:** Applies the new mask to the original image, making it ready to use with the ControlNet module, Gallery, etc. and exits the Tool.\
\
**InPaint:** Sets the masked image as the ControlNet image, and loads the CN InPaint model. This is a quick way to configure ControlNet to fill the empty areas in the image, just click Dream to generate the image when the setup is complete.

**Kontext-Fill:** Set the masked image as the Kontext reference image, then enter a prompt like “Fill the clear area with…” to generate the missing parts. [Learn more](/sogni-docs/sogni-studio/creating-images/generation-settings/context-editing-and-mixing/context-fill.md)

<figure><img src="/files/YbKiAVOvuYnEutWMVYIX" alt=""><figcaption></figcaption></figure>

***

### How to use Masks within Sogni

**Step One**

Open the image you'd like to create a mask within and select the Mask Tool from the top Toolbar.

**Step Two**

Highlight the area you would like to use as a mask, then select InPaint to open up your image with your Mask in ControlNet with the InPaint CN Model applied.

<figure><img src="/files/KA5g9LFLvedGRA1Avobm" alt=""><figcaption></figcaption></figure>

**Step Three**

Enter your prompt within the prompt field to regenerate your image with your Mask ✨

***

### Tip: Using Segementation to mask a subject / background

The Segmentation preprocessor in ControlNet can help you to automatically mask the subject/background of your image. Here is how to use it:<br>

1\. Drag the image you wish to mask to the controlNet module.

2\. Select the Segmentation preprocessor (second one from the bottom on the left side of the CN image)

3\. Enable the subject or background mask button and make sure you have transparent background selected. These should create the mask you need with only the subject or background.

4\. If you need to remove more areas from the mask, click the “Send to Main Window” button to the right of the CN image, then activate the "Lasso Eraser / Mask Tool".

***

**Need help? Ask in our Discord!**

For any questions regarding the use of Sogni, tips, suggestions, bugs, sharing art, discussing AI and life, or simply hanging out... Join our Discord community!\
\
[Join Sogni Discord](https://discord.com/invite/2JjzA2zrrc) ✨<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sogni.gitbook.io/sogni-docs/sogni-studio/creating-images/other-tools/masks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
