# **Mask Maker Processor**
## Overview
The **Mask Maker** processor automatically finds and segments objects in your image, producing one mask per object and optional Boolean-composite masks. Simply tell it what to look for and where to save the results.
---
## Example Usage
```yaml
- processor:
processor: "mask_maker"
inputs:
source: "input/car_photo.png"
params:
cache_json: "cache/car_masks.json" # optional: caches full JSON response
mask_prompt: "car., window, license plate"
threshold: 0.2 # detection confidence cutoff
mask_output: > # compose new masks
body: car - window;
plate: body AND license_plate
outputs:
body: "cache/mask_body.png"
plate: "cache/mask_plate.png"
annotated: "output/annotated_car.png"
assigns:
left: "masks_left" # bbox of all masks combined
top: "masks_top"
right: "masks_right"
bottom: "masks_bottom"
width: "masks_width"
height: "masks_height"
body_left: "body_left" # per-mask bbox
body_top: "body_top"
plate_left: "plate_left"
plate_top: "plate_top"
```
---
## Parameters
| Key | Type | Req’d | Default | Description |
| ------------- | ------- | :---: | ------------ | -------------------------------------------------------------------------------------- |
| `cache_json` | `str` | No | — | If provided, caches & reuses the full JSON response |
| `mask_prompt` | `str` | Yes | — | Comma-separated object names; suffix `.` → keep only the top-scoring instance per term |
| `threshold` | `float` | No | `0.2` | Confidence cutoff for object detection |
| `mask_output` | `str` | No | identity map | Single-line infix DSL to define composite masks; overrides the one-per-term defaults |
> **Default `mask_output`** (when omitted)
> Produces one mask per prompt term:
> `car:car; window:window; license_plate:license_plate`
---
## Mask-Output DSL
Compose new masks by combining detected masks with Boolean operators.
Syntax per segment:
```
: term [OP term …] [; : …]
```
- **Evaluate left → right**, no parentheses.
- **Mask names** are your chosen output labels (they’ll also become file keys).
| Syntax | Alias | Meaning | Example |
| ------------------- | ----- | --------------------- | ----------- |
| `A & B` | `AND` | intersection | `1 & 0 → 0` |
| `A + B`
`A \| B` | `OR` | union | `1 + 0 → 1` |
| `-` (binary) | — | difference (`A & !B`) | `1 - 1 → 0` |
| `!A` | `NOT` | complement | `!1 → 0` |
| `A ^ B` | `XOR` | exclusive or | `1 ^ 1 → 0` |
- Operators and mask names are **case-insensitive**.
- **Note:** `-B` as a unary prefix is **not** supported; use `!B` instead.
> **Example:**
>
> ```yaml
> mask_output: "body: car - window; plate: body & license_plate"
> ```
---
## Outputs
| Key | Required | Description |
| ----------- | :------: | -------------------------------- |
| `` | Yes | Path to each generated mask PNG |
| `annotated` | No | Path to auto-annotated image PNG |
---
## Assigns
After processing, you’ll receive:
- **Global bounding box** of all masks combined:
`left, top, right, bottom, width, height`
- **Per-mask bounding boxes**:
`_left, _top, `\_right, `_bottom, `\_width, `_height`
---
Just declare:
1. **What** to detect (`mask_prompt`)
2. **Where** to save each mask (`outputs`)
3. **How** to compose them (`mask_output` DSL)