Automated segmentation and volumetric analysis of individual plants from 3D point cloud scans (3D camera) using spatial clustering and voxel-based measurements.
- Automatic Segmentation: Automatically detects and separates individual plants using X-axis distribution analysis
- Robust Cleaning: Removes background walls, pots, and outliers using color and spatial filtering
- Volumetric Analysis: Multi-resolution voxel-based volume and surface area calculation
- Visual Outputs: Generates 3D meshes (OBJ), point clouds (PLY), and diagnostic visualizations
- Batch Processing: Process multiple scans automatically
- Interactive Mode: User-friendly prompts
For plant phenotyping, growth analysis, and agricultural research.
- Python 3.8 or higher
- pip package manager
- Clone the repository:
git clone https://github.com/yourusername/Plant-Point-Cloud-Segmentation.git
cd Plant-Point-Cloud-Segmentation- Install dependencies:
pip install -r requirements.txtSegment a multi-plant point cloud into individual plants:
python segmentation.pyFollow the interactive prompts:
- Mode 1: Single file processing
- Mode 2: Batch processing (entire folder)
Input: Multi-plant PLY point cloud
Output:
individual_plants/plant_01.plythroughplant_0N.plyplants_cleaned.ply(cleaned combined point cloud)segmentation_histogram.png(visualization)
Plant point cloud Processing. (A) Raw point cloud from 3D-Camera; (B) Cleaned point cloud before segmentation
Calculate volume and surface area for each plant:
python volumetric_analysis.pyInput: Individual plant PLY files (from Step 1)
Output (per plant, at 3 resolutions):
plant_01_coarse_voxels_10mm.obj- 3D voxel mesh (viewable in Meshlab/Blender)plant_01_medium_voxels_5mm.obj- Medium resolution meshplant_01_fine_voxels_3mm.obj- Fine resolution meshplant_01_*_voxels_*mm.ply- Voxel centers as point cloudsplant_measurements.csv- Summary with volume (cm³) and area (cm²)
(A) Individual plant point cloud; (B) 3D voxel of plant
# 1. Segment plants from the scan
python segmentation.py
> Input PLY file: my_scan.ply
> Number of plants: 7
> Output directory: individual_plants
# 2. Analyze volumes
python volumetric_analysis.py
> Input directory: individual_plants
> Output directory: results
> Base voxel size: 5individual_plants/
├── plant_01.ply (15,234 points)
├── plant_02.ply (18,901 points)
├── plant_03.ply (14,567 points)
└── ...
results/
├── plant_01_cleaned.ply
├── plant_01_coarse_voxels_10mm.obj
├── plant_01_medium_voxels_5mm.obj
├── plant_01_fine_voxels_3mm.obj
└── plant_measurements.csv
CSV Output:
| Plant | Points | Coarse Vol (cm³) | Medium Vol (cm³) | Fine Vol (cm³) |
|---|---|---|---|---|
| plant_01 | 15,234 | 1,245.3 | 1,189.7 | 1,156.2 |
| plant_02 | 18,901 | 1,567.8 | 1,498.4 | 1,467.9 |
| Parameter | Default | Description |
|---|---|---|
num_plants |
7 | Expected number of plants in scan |
nb_neighbors |
20 | Neighbors for outlier removal |
std_ratio |
2.0 | Standard deviation threshold |
| Parameter | Default | Description |
|---|---|---|
input_unit |
mm | Units of input files (m/cm/mm) |
voxel_size_mm |
5.0 | Base voxel size (coarse=2x, fine=0.5x) |
dilate_iters |
1 | Dilation iterations to fill gaps |
- Python >= 3.8
- open3d >= 0.13.0
- numpy >= 1.19.0
- scipy >= 1.5.0
- matplotlib >= 3.3.0
- scikit-learn >= 0.24.0
See requirements.txt for a complete list.
- Format: PLY (binary or ASCII)
- Coordinates: X, Y, Z in millimeters (configurable)
- Colors: RGB values (0-255 or 0-1)
- Structure: Multi-plant scene with pots visible
- X-axis: Horizontal (plant separation axis)
- Y-axis: Depth (front-to-back)
- Z-axis: Vertical (height)
- Background Removal: Depth-based filtering using white pot labels
- Pot Removal: Y-coordinate analysis with color filtering
- Outlier Removal: Statistical outlier detection (Open3D)
- Automatic Segmentation: Histogram-based peak/valley detection in X-axis
- Boundary Optimization: Automatic merging/splitting to match plant count
- Cleaning: Color filtering (green/yellow) + DBSCAN spatial clustering
- Voxelization: Convert point cloud to 3D occupancy grid
- Dilation: Fill small gaps using 6-neighborhood morphology
- Volume: Count occupied voxels × voxel volume
- Surface Area: Face counting method at voxel boundaries
Solution: Ensure the input directory contains .ply files and the path is correct.
Solution:
- Check input units match your data (mm/cm/m)
- Verify PLY files contain valid point data
- Try disabling color filtering if plants aren't green
Solution:
- Adjust
num_plantsparameter - Check if plants are clearly separated in the X-axis
- Verify background/pots are properly removed
Solution: Adjust cleaning parameters:
nb_neighbors: Higher = more aggressive cleaningstd_ratio: Lower = more aggressive cleaning
If you use this code in your research, please cite:
@software{plant_point_cloud_segmentation,
title={Plant Point Cloud Segmentation},
author={Worasit Sangjan},
year={2024},
url={https://github.com/WorasitSangjan/Plant-Point-Cloud-Segmentation}
}This project is open source under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or issues, please open an issue on GitHub or contact [worasitsangjan.ws@gmail.com]
- Built with Open3D
- Inspired by plant phenotyping research in precision agriculture

