segfix
A GUI tool to fix the instance segmentation of tree point clouds. Load a segmented LiDAR cloud, see each tree in its own colour, and correct mistakes by lassoing points and reassigning, splitting off, or dismissing them — then save back to a corrected version of the input, retaining all fields.
Built on napari for fast 3D rendering and point selection.
Contributing
Feedback, issues, and PRs all welcome. For issues please use GitHub issues (not a personal message) so the community can benefit.
Install
Requires Python 3.10–3.12 (napari/Qt do not yet ship wheels for 3.13+).
git clone https://github.com/tim-devereux/segfix.git
cd segfix
conda create -n segfix python=3.11
conda activate segfix
pip install -e .
Run
segfix
# or generate a practice cloud with built-in segmentation errors first:
python scripts/make_sample.py sample.ply
python scripts/make_sample.py --format las sample.las # arbor-shaped LAS
segfix will open a startup dialog. Double-click
a recent project to reopen it, or click New Project… to import a point cloud
file. Importing copies the file into a new project folder (created inside the
directory you pick, named after the source file) and opens that copy — edits are
always saved to the copy, never the original source file.
Every project opened this way is recorded in ~/.config/segfix/registry.json
(a plain JSON file) so it shows up in the "Recent projects"
list next time — most-recently-opened at the top and preselected, each row
showing how long ago it was last opened.
The per-point tree ID field is auto-detected (treeID, PredInstance,
label, …); override with --label-field NAME if needed.
Accepted formats
Binary PLY — RGB-segmented (raycloudtools) or with a label field — and
LAS. Both store their points as fixed-size records at a known offset, which
is what lets treecatalog.py memory-map a whole plot, read back just the points
of one tree, and on save patch only the label bytes that changed.
raycloudtools output
raycloudtools' rayextract trees writes <plot>_segmented.ply — a binary PLY with no label column, each
point instead coloured by tree (x y z time nx ny nz red green blue alpha,
double xyz). segfix detects the RGB encoding, maps each distinct colour to a
tree, and treats pure black (0, 0, 0) as unsegmented. Import the .ply
directly; Save patches the colour bytes of points whose tree changed, in
place, so the file stays in exactly the format rayextract produced.
One caveat: noise (X) and unassigned points are both written back as black,
so once such a file is reloaded the two are indistinguishable (segfix's
.segfix.json sidecar still remembers which were noise for the current
project). New trees created during editing (N, splits) get a deterministic
colour derived from their id.
arbor output
arbor's pipeline (arbor segment …) writes
<plot>_output/<plot>_segmented.laz — a point cloud with a per-point treeID
Extra-Bytes column (0 = unassigned). Import that .laz directly: segfix
decompresses it to a .las working copy in the project folder (the original
.laz is never touched), you fix the treeIDs with the workflow below, and
Save patches the .las in place and re-compresses a fresh .laz beside
it for arbor to re-read.
One caveat: if a cloud's treeID column is an unsigned type, points you
dismiss as noise (X) are written back as 0 (unassigned) — segfix's own
.segfix.json sidecar still remembers they were noise, but a reader of the LAS
alone cannot tell noise from unassigned. (arbor writes a signed treeID, so
this does not apply to its output.)
Editing workflow
Navigation matches CloudCompare: clouds open Z-up, left-drag rotates, right-drag pans, wheel zooms.
Two tables stack in the right-hand panel. All Trees (top) lists every tree
in the file, with a ✓ once it has been reviewed — double-click a row to
load that tree plus its spatial neighbours into the 3D view. Selected Tree +
Neighbours (below) is the review queue for what's currently loaded: a Done
checkbox per tree, a 👁 column to hide one from the view, a Fade column to
ghost one (still shown, still selectable), and the Prev / Done buttons. Both
read the same <cloud>.segfix.json sidecar, written next to the working copy,
so a half-finished plot resumes where you left off.
-
Double-click a tree in All Trees. The camera flies to it and a wireframe box marks it. To declutter a crowded view, use the 👁 (hide) or Fade column in the lower table on specific trees — or Hide others / Fade others in the top-bar View group to do it to every loaded tree except the one under review. Fading keeps a tree visible as faint context and still lets the lasso grab its points; hiding removes it from both.
-
Inspect it. If it's correct, press Space — the tree is marked done, progress is saved, and the next unfinished tree in the loaded set becomes current. That's the loop.
-
If it needs fixing, select points with the lasso: press L, drag a freehand loop (Shift adds), Esc to go back to navigating. The tree under review is always the implicit target.
Key Operation SpaceMark current tree done, jump to next unfinished ←/→Previous / next tree (without marking done) LLasso select Ctrl+LLasso, but only points already in the current tree — grabs a clean patch out of an overlapping crown EscBack to camera / navigation AAdd selection to the current tree (missing branches, unassigned canopy) NSplit selection off as a new tree (it joins the queue unreviewed) UUnassign selection — or the whole current tree if nothing is selected XMark selection as noise — or the whole current tree if nothing is selected (dismiss a bush/wall in one key) Delete/BackspaceSame as X(mark noise)HShow/hide the unassigned + noise points CCross section on/off Shift+LDraw a lasso-section outline Shift+CLasso section on/off Ctrl+Z/Ctrl+Shift+ZUndo / Redo Ctrl+SSave Project To move stray points to a neighbour instead, lasso them and click one of the → id buttons in the Current tree panel — one per tree within "reach" metres of this one. Clicking that neighbour's table row to make it current and pressing
Adoes the same thing.To merge an over-segmented fragment back in, lasso the whole fragment and press
A; there is no separate merge key. -
For a crowded canopy, two tools in the top bar cut the view down. Both fold into the same visibility as the 👁 column, so hidden points are also unselectable and the lasso can't grab through them:
- Cross section (
C) — a slab along X, Y or Z, set with two sliders. - Lasso section (
Shift+C) — same idea, but the kept region is an outline you draw (Shift+L, then drag). It's frozen into a point mask as you release, so the camera moves freely afterwards.
Both reset when a new tree is loaded.
- Cross section (
-
Leftover unassigned points may hide missed trees: they're loaded alongside every tree you open, so lasso one and press
Nto promote it to a tree of its own (it joins the queue unreviewed). -
Save (
Ctrl+S) writes to the project copy, never the original import. It patches only the points whose label changed, in place, so the header and every other column are untouched byte for byte.
Layout
| File | Responsibility |
|---|---|
model.py |
PointCloud data + undo/redo (diff-based) |
io.py |
whole-cloud load/save (binary PLY, LAS/LAZ), label-field and RGB-segmentation detection |
operations.py |
pure, UI-agnostic label edits (reassign/split/unassign/noise) |
analysis.py |
which trees touch which, by sampled point distance (KD-tree) |
lasso.py |
3D screen-space lasso: camera projection + polygon test |
viewer.py |
napari layer + label→colour mapping |
widgets.py |
Qt dock panel wiring selection → operations |
icons.py |
inline SVG icons for the panel buttons and window |
treecatalog.py |
default mode: memory-mapped tree-label grouping, neighbour load + write-back (TreeCatalog = PLY, LasCatalog = LAS, open_catalog picks) |
scene_ui.py |
tree table + scene controller for the default mode |
registry.py |
on-disk list of recently opened files/projects |
workspace.py |
project folders: copy (or decompress .laz→.las) an imported file, never touch the source |
startup_ui.py |
startup dialog: pick a recent entry or start a new project |
app.py |
segfix CLI entry point |
Tests
pytest # core model, operations, and IO round-trip (no GUI needed)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file segfix-0.1.0.tar.gz.
File metadata
- Download URL: segfix-0.1.0.tar.gz
- Upload date:
- Size: 72.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
098112a97c30d198cd9e70dafcadf158d735b1362867e08cca1ae9cf00e711e9
|
|
| MD5 |
cb063b64d46839acdcc4b42e6aadd289
|
|
| BLAKE2b-256 |
593d2780d0a0480dc86a963aa098f39a1e9d499c0af3de66d4943d1d0209290b
|
Provenance
The following attestation bundles were made for segfix-0.1.0.tar.gz:
Publisher:
publish.yml on tim-devereux/segfix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
segfix-0.1.0.tar.gz -
Subject digest:
098112a97c30d198cd9e70dafcadf158d735b1362867e08cca1ae9cf00e711e9 - Sigstore transparency entry: 2667777747
- Sigstore integration time:
-
Permalink:
tim-devereux/segfix@f179b125bd2f90dbd853b44e43d127100d57e7bc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tim-devereux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f179b125bd2f90dbd853b44e43d127100d57e7bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file segfix-0.1.0-py3-none-any.whl.
File metadata
- Download URL: segfix-0.1.0-py3-none-any.whl
- Upload date:
- Size: 65.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34d7fdc037940b91df42a6ac22c0387278b3a660f4fb420987989cf8dbc423b5
|
|
| MD5 |
c21724c8ac5e81b6f3a5af7356205955
|
|
| BLAKE2b-256 |
d01765e2161cf6432a4ff9c9890972c57786bc9a671585f78a7ba0e8f8161dba
|
Provenance
The following attestation bundles were made for segfix-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on tim-devereux/segfix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
segfix-0.1.0-py3-none-any.whl -
Subject digest:
34d7fdc037940b91df42a6ac22c0387278b3a660f4fb420987989cf8dbc423b5 - Sigstore transparency entry: 2667777831
- Sigstore integration time:
-
Permalink:
tim-devereux/segfix@f179b125bd2f90dbd853b44e43d127100d57e7bc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tim-devereux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f179b125bd2f90dbd853b44e43d127100d57e7bc -
Trigger Event:
push
-
Statement type: