TreeDecimate is a tool for reducing the complexity of tree files by decreasing the number of segments while preserving topology and essential geometric features. It maintains branch junction locations and overall tree structure.
treedecimate <tree_file> <factor> segments
Reduce to every Nth segment:
treedecimate forest.txt 2 segments
treedecimate <tree_file> ratio <max_ratio>
Remove segments based on length-to-width ratio:
treedecimate forest.txt ratio 3
Reduces tree complexity by keeping every Nth segment:
- Factor 2: Keeps every 2nd segment (roughly half complexity)
- Factor 3: Keeps every 3rd segment (roughly one-third complexity)
- Higher factors: Greater complexity reduction
Removes segments with low length-to-width ratios:
- Length: Distance between segment endpoints
- Width: Segment diameter (2 × radius)
- Ratio threshold: Minimum length/width ratio to retain segment
The tool maintains tree structure by:
- Preserving junctions: All branch points are retained
- Maintaining connectivity: Parent-child relationships preserved
- Keeping terminals: End segments (leaves) are always kept
- Preserving roots: Root segments remain unchanged
Reduce complexity by half:
treedecimate detailed_trees.txt 2 segments
Reduce to one-third complexity:
treedecimate forest.txt 3 segments
High decimation for simplified structure:
treedecimate complex_tree.txt 5 segments
Remove very short segments:
treedecimate noisy_trees.txt ratio 2
Keep only longer segments:
treedecimate forest.txt ratio 5
Aggressive ratio decimation:
treedecimate detailed_scan.txt ratio 10
- Start from root segment (always preserved)
- Count segments along each branch
- Keep every Nth segment based on decimation factor
- Force preservation at branch junctions
- Always preserve terminal segments
- Calculate length and width for each segment
- Compute length-to-width ratio
- Remove segments below threshold ratio
- Re-parent child segments to preserved parents
- Reindex segment relationships
- Branch junction positions maintained exactly
- Overall tree shape preserved
- Terminal branch locations unchanged
- Root position and orientation preserved
- No disconnected segments created
- Topology remains valid
- Parent-child relationships consistent
- Tree remains a connected structure
- Reduce storage requirements for large forest datasets
- Optimize memory usage for processing
- Speed up analysis algorithms
- Create simplified models for real-time rendering
- Generate level-of-detail (LOD) representations
- Improve interactive visualization performance
- Speed up computational algorithms
- Reduce processing time for forest analysis
- Create manageable datasets for statistical analysis
- Reduce file sizes for network transfer
- Optimize datasets for remote processing
- Create compact representations for sharing
treedecimate forest.txt 2 segments # Medium detail
treedecimate forest.txt 4 segments # Low detail
treedecimate reconstructed_trees.txt ratio 3
treedecimate large_forest.txt 3 segments
treedecimate complex_trees.txt ratio 5
- Quality: High geometric fidelity
- Performance: Moderate improvement
- Use case: Balanced applications
- Quality: Good overall structure
- Performance: Significant improvement
- Use case: Visualization and analysis
- Quality: Basic structure preserved
- Performance: Maximum improvement
- Use case: Rough analysis, thumbnails
- Only works on full tree structures (not trunk-only files)
- Cannot create new junctions or merge branches
- Maintains original branching patterns
- Fine-scale geometric details may be lost
- Some biological realism may be reduced
- Very high decimation may oversimplify structure
The tool generates:
<input>_decimated.txt: Simplified tree file- Maintains same format and attribute structure
- Preserves all attributes for retained segments
The decimated trees maintain:
- Valid tree topology
- Consistent parent-child relationships
- Proper segment indexing
- All required attributes
- Decimation respects tree hierarchy and biological structure
- Junction detection ensures structural integrity
- Segment counting is branch-aware for natural decimation
- For more detailed information on decimation algorithms, refer to the
TreeDecimatesource code attreetools/treetools/treedecimate/treedecimate.cpp.