Home (All Topics) → Technology → Software → AI-Created Software
By Marios Alexandrou on September 9, 2026.
The following AI-generated aka vibe-coded software. The software is specific to my needs and my system and may not work for you or your system. Support is limited, but if you report a bug I'll certainly look into it. All code is provided in a zip file for you to review should you choose.
A small desktop app (Tkinter) for turning a depth map into a grayscale mask centred on a depth of your choosing.
You load a depth map, paint over the region you want to treat as the reference depth, and the tool produces an image where that depth is pure white and everything else fades toward black as it moves away from the reference — in either direction, whether it sits in front of or behind the reference.
sudo apt install python3-tk)pillownumpy
The loaded image is converted to 8-bit grayscale. Each pixel’s value (0–255) is its depth.
The reference depth is the mean grayscale value of every pixel you painted.
For each pixel the tool computes diff = |depth − reference|.
That difference is divided by the falloff range, clamped to 0–1, and inverted:
output = (1 − min(diff / falloff, 1)) × 255
So a pixel at exactly the reference depth is 255 (white), a pixel a full falloff range away is 0 (black), and anything beyond is clamped to black. The falloff is symmetric — depth 100 and depth 200 are equally distant from a reference of 150.
Auto falloff range (on by default) sets the falloff to the largest difference present in the image, so the output always uses the full 0–255 range. Turn it off to set the falloff manually with the slider (1–255), which gives you a tighter, more selective band around the reference.
| Control | What it does |
|---|---|
| Load Depth Image… | Opens a depth map (.png, .jpg, .jpeg, .tif, .tiff, .bmp, .exr) |
| Clear Painted Mask | Wipes the painted region and the current result |
| Save | Re-saves into the folder used last time; falls back to Save As… if nothing has been saved yet |
| Save As… | Prompts for a parent folder and creates a new result folder inside it |
| Load Project | Reopens a previously saved result from its sidecar .json |
| Actual Size / 2x / 0.5x / Fit to Window | Zoom controls for both preview panes |
| Brush size | 2–200 px, measured in display pixels |
| Auto falloff range | Toggles automatic vs. manual falloff |
| Falloff | Manual falloff value, 1–255 (enabled only when auto is off) |
The left pane shows the source image with your painted overlay; the right pane shows the generated result. Both scroll and share the same zoom level.
Save As… asks for a parent folder, then creates a subfolder named after the source image. If a folder with that name already exists, it appends _01, _02, and so on rather than overwriting anything.
Inside that folder, using bedroom.png as an example source:
bedroom/
├── bedroom_with_reference_set.png # the generated grayscale result
├── bedroom_mask.png # the painted mask on its own (white = painted)
├── bedroom.json # sidecar metadata (also the project file)
└── bedroom.png # symlink or hard link back to the source image
The source image is linked rather than copied. A symlink is tried first, then a hard link. Symlinks on Windows need Developer Mode or admin rights; hard links need the source and destination to be on the same volume. If both fail you get a warning, but the result files are still written. The result filename always carries the _with_reference_set suffix so it can’t collide with the linked source.
| Field | Meaning |
|---|---|
source_image |
Absolute path to the original depth map |
linked_image_file |
Filename of the link created in the result folder |
link_type |
symlink, hardlink, unchanged, or null if linking failed |
image_width, image_height |
Source dimensions in pixels |
reference_depth |
Mean depth under the painted mask (0–255) |
auto_falloff_range |
Whether auto falloff was active |
falloff_range |
The falloff value actually used |
brush_size_px |
Brush size at save time |
mask_file |
Filename of the saved mask |
painted_pixel_count |
Number of painted pixels |
painted_coverage_pct |
Painted pixels as a percentage of the image |
painted_bounding_box |
x_min/y_min/x_max/y_max of the painted area, or null |
generated_at |
ISO 8601 timestamp |
Load Project takes one of these .json files (or a folder containing one) and restores the source image, the painted mask, the brush size, and the falloff settings, then regenerates the preview. If the mask file is missing or its resolution doesn’t match the image, you get a warning and the remaining settings are applied anyway.
The heading above the result pane reads (unsaved) or (saved as <path>) so you can tell at a glance whether the preview matches what’s on disk.
The app writes depth-map-reference-mask.ini next to the script, storing the window geometry, whether the window was maximized, the last folder used for loading, and the last parent folder used for saving. Deleting the file just resets the app to its defaults.
If you want a custom title-bar and taskbar icon, place these alongside the script:
depth_mask_app.ico
Resources/depth_mask_app_icon_16.png
Resources/depth_mask_app_icon_32.png
Resources/depth_mask_app_icon_64.png
All of it is optional. Missing or unreadable icons print a one-line note to the console and the app falls back to the default Tk icon.
On Windows the app also sets an explicit AppUserModelID (so the taskbar shows the app’s icon instead of python.exe’s) and marks itself DPI-aware (so “Actual Size” really is 1:1 under display scaling above 100%).
L, so a 16-bit or 32-bit depth map is quantized to 256 levels on load. Fine banding in the output is usually this, not the falloff maths.depth_mask_app.py; the actual filename is depth-map-reference-mask.py.

Leave a Reply