Robust 3D Mask Engine Performance and Interactive Stability
InVesalius's 3D mask editor suffers from two critical bottlenecks: slow single-threaded Python geometry math that freezes the UI on high-resolution medical images, and a memory-intensive undo system that copies entire 500×500×500 voxel matrices on every edit, causing out-of-memory crashes on resource-constrained machines. This project addresses both problems through three tightly integrated deliverables. First, the heavy polygon-to-mask projection math will be ported from Python's skimage into multi-threaded Rust via PyO3, using zero-copy rust-numpy bindings to eliminate expensive matrix duplication across the Python/Rust boundary. Second, a new delta-encoded Undo/Redo engine will be built that records only the coordinates of changed voxels rather than full volume snapshots, paired with a disk-backed crash-recovery system and a visual history panel in wxPython for intuitive workflow management. Third, a native interactive 3D Brush Tool will be introduced, allowing users to paint or erase mask selections directly onto the 3D model with a configurable voxel depth, powered by native Rust ray-casting algorithms. Deliverables include a working invesalius_rs Rust module replacing the skimage dependency, the DeltaHistoryStack integrated across all 3D tools (polygon, brush, select parts, thresholding), the Mask3DEditorState decoupling class to eliminate ghost polygon UI bugs, cross-platform unit tests and CI validation, and a contributor benchmark report comparing performance against the current v3.0 baseline.
Project details
Technologies
Not listed in the archive