Skip to content

Commit 968a29f

Browse files
committed
Docs: add details about selection mask processing and related settings
1 parent 7eec5d4 commit 968a29f

File tree

6 files changed

+80
-3
lines changed

6 files changed

+80
-3
lines changed
38.3 KB
Loading
36.4 KB
Loading
40.6 KB
Loading
21.2 KB
Loading

docs/src/components/ImageGrid.astro

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import { Image } from "astro:assets";
33
4-
const { images, captions } = Astro.props;
4+
const { images, captions, layout } = Astro.props;
55
66
function findImage(img: string) {
77
const imageFiles = import.meta.glob<{ default: ImageMetadata }>(
@@ -13,9 +13,14 @@ function findImage(img: string) {
1313
}
1414
return imageFiles[imgFile]();
1515
}
16+
17+
let gridStyle = "grid-template-columns: repeat(auto-fit, minmax(320px, 1fr))";
18+
if (layout === "row") {
19+
gridStyle = "grid-template-columns: repeat(3, 1fr)";
20+
}
1621
---
1722

18-
<div class="image-grid">
23+
<div class="image-grid" style={gridStyle}>
1924
{
2025
images.map((img: string) => (
2126
<div>
@@ -29,7 +34,6 @@ function findImage(img: string) {
2934
<style>
3035
.image-grid {
3136
display: grid;
32-
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
3337
gap: 1rem;
3438
}
3539
.image-grid > div {

docs/src/content/docs/selections.mdx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ title: Selection Fill
33
description: Guide to working with selection inpainting in Krita AI Diffusion
44
---
55

6+
import { Aside } from '@astrojs/starlight/components'
67
import PluginIcon from '../../components/PluginIcon.astro'
8+
import ImageSample from '../../components/ImageSample.astro'
9+
import ImageGrid from '../../components/ImageGrid.astro'
710

811
Using selections to modify parts of the image is a key feature of the plugin. It
912
allows you to apply AI generation exactly where you want. You can work on an
@@ -140,3 +143,73 @@ In custom generation menu, select your mask as context. You can reuse it any tim
140143
![custom-inpaint-context-menu](https://github.com/Acly/krita-ai-diffusion/assets/6485914/c79a6009-1fa3-4173-b123-592c4afc2cfc)
141144

142145

146+
## Selection settings
147+
148+
Your selection defines a basic mask where new content is generated. To make
149+
it more robust and allow changes to be integrated with the rest of the image,
150+
the mask is usually processed by the plugin before it is used. This section goes
151+
into more detail and shows how diffusion settings influence the mask.
152+
153+
### Mask types
154+
155+
<ImageGrid layout="row" images={[
156+
"selections/masks-selection.webp",
157+
"selections/masks-denoising.webp",
158+
"selections/masks-alpha.webp"]}
159+
captions={{
160+
"selections/masks-selection.webp": "Selection",
161+
"selections/masks-denoising.webp": "Denoising mask",
162+
"selections/masks-alpha.webp": "Blend mask (blue)"
163+
}}
164+
/>
165+
166+
The plugin derives two masks from the original selection, which are used for
167+
different purposes.
168+
* The <span style="color: #cd5c12; font-weight: bold;">red area</span> corresponds to the original
169+
selection. It always receives changes at full strength (the value
170+
configured via the strength slider).
171+
* The <span style="color: #d97706; font-weight: bold;">orange area</span> is a tiny offset, which
172+
helps to avoid issues with outlines of objects when the selection is a bit too
173+
tight. It also receives changes at full strength.
174+
* The <span style="color: #94bc16; font-weight: bold;">green/yellow area</span> visualizes how
175+
strength gradually decreases towards the edges. The green inner areas are
176+
generated at higher strength (more denoising steps), while the yellow outer
177+
areas are generated at low strength. Remember that generation happens in
178+
multiple steps: the sections further away from the selection remain completely
179+
unchanged initially and are only included in the final fine tuning steps.
180+
* The <span style="color: #3b82f6; font-weight: bold;">blue area</span> is the blend mask. It is
181+
independent from generation, and only used to perform alpha composition of the
182+
result with the original image. At the inner edge of the blue area (dark blue)
183+
100% of the result will be applied. Towards the outer edge (light blue) it becomes
184+
gradually more transparent.
185+
186+
_Note: with typical settings the masks are significantly smaller than in this
187+
visualization._
188+
189+
### Settings
190+
191+
<ImageSample src="selections/masks-settings.webp" scale={1.25} alt="Mask settings" />
192+
193+
In the Diffusion settings there are two values that influence the masks:
194+
* **Selection Feather**: this controls the falloff area of the denoising mask
195+
(green/yellow area). It is defined in percent relative to the selection size.
196+
* **Selection Blend**: this controls the size of the blend mask (blue area). It
197+
is defined in absolute pixels.
198+
199+
If both of these are set to 0, all automatic mask processing is disabled.
200+
This can make sense if you want to have full control over the selection mask.
201+
202+
<Aside type="note">
203+
The transition area (green/yellow) is scaled according to the **strength**! At 100% strength
204+
it has the full size defined by the settings, but at 50% strength it will be only half as big.
205+
Low strength refinement usually blends well on its own, and uses minimal feathering.
206+
</Aside>
207+
208+
There are two more settings which can currently only be configured by editing
209+
`settings.json`. You can find the file via the link at the bottom of the
210+
Settings dialog. The settings are:
211+
* **selection_min_transition**: minimum size in pixels of the transition area
212+
(green/yellow).
213+
* **selection_grow_offset**: size in pixels of the orange offset area. This is
214+
usually a very small value.
215+

0 commit comments

Comments
 (0)