Pipeline overview
Running the full pipeline
Thepipeline command chains all three stages and stores everything in one session:
The
--open flag launches the system file manager pointing at the session directory once the pipeline finishes. It is enabled by default.Stage-by-stage walkthrough
Stage 1: Object Detection
The What gets saved:
The session status transitions from
detect command converts each image to HSV color space, applies a color mask around the target hue, runs morphological operations to clean noise, and extracts contour features.| File | Description |
|---|---|
detection/features.csv | One row per detected object: image_filename, contour_index, area, perimeter, centroid_x, centroid_y, circularity, aspect_ratio, solidity, extent |
detection/<image>/01_hsv.png | HSV-converted source image |
detection/<image>/02_mask_initial.png | Raw color mask before morphology |
detection/<image>/03_mask_closed.png | Mask after MORPH_CLOSE |
detection/<image>/04_mask_morph_final.png | Mask after MORPH_OPEN |
detection/<image>/05_raw_contours.png | All contours before area filtering (red) |
detection/<image>/06_filtered_contours_final.png | Contours that passed the area filter (green) |
DETECTING → DETECTION_DONE on success.Stage 2: K-Means Clustering
The What gets saved (one sub-directory per image):
Features used for clustering:
cluster command reads features.csv, normalises the six morphological features with StandardScaler, runs the elbow method to pick the optimal K, and fits a KMeans model.| File | Description |
|---|---|
clustering/<image>/<image>_clustered.csv | features.csv with an added cluster column |
clustering/<image>/elbow_method.png | Inertia vs K with the selected elbow marked |
clustering/<image>/silhouette_analysis.png | Silhouette score vs K (when compute_silhouette=True) |
clustering/<image>/cluster_distribution.png | Scatter of centroid positions coloured by cluster |
clustering/<image>/morphological_scatter.png | Area vs circularity scatter coloured by cluster |
clustering/<image>/clusters_visualization.png | Centroid overlays on the filtered contours image |
clustering/<image>/cluster_groups.png | Rotated bounding rectangles per cluster |
area, perimeter, circularity, aspect_ratio, solidity, extent. Centroid coordinates are not used as clustering features — they are preserved for spatial analysis only.The session status transitions from CLUSTERING → CLUSTERING_DONE.Stage 3: Spatial Analysis
The What gets saved:
The session status transitions from
analyze command reads each _clustered.csv file and computes descriptive statistics and the Average Nearest Neighbor (ANN) index for each cluster.| File | Description |
|---|---|
analysis/<image>/descriptive_stats.csv | Per-cluster mean/std/min/max for area and perimeter |
analysis/<image>/ann_results.csv | ANN R-index and interpretation (Clustered / Random / Dispersed) per cluster |
analysis/<image>/ann_results.png | Bar chart of R-index values with the random baseline (R=1) marked |
analysis/<image>/spatial_distribution_map.png | Scatter map of objects by cluster (Y-axis inverted to match image coordinates) |
analysis/<image>/boxplot_area.png | Boxplots of morphological features by cluster |
ANALYZING → COMPLETED.Performance metrics
Afterpipeline finishes it prints a metrics table showing how long each stage took and peak memory usage:
metadata.json so you can retrieve them later.
