Segments Analysis
This module provides a class for analyzing segmentation results.
It includes methods to analyze segmentation maps, compute pixel counts and percentages for each category, and generate statistics for the analysis results.
| CLASS | DESCRIPTION |
|---|---|
SegmentationAnalyzer |
A class for analyzing segmentation results. |
SegmentationAnalyzer
¶
A class for analyzing segmentation results.
This class provides methods to analyze segmentation maps, compute pixel counts and percentages for each category, and generate statistics for the analysis results.
| METHOD | DESCRIPTION |
|---|---|
analyze_segmentation_map |
Analyzes a segmentation map to compute pixel counts and percentages. |
analyze_results |
Analyzes segmentation data and saves counts and percentages to CSV files. |
generate_category_stats |
Generates statistics for category counts or percentages. |
analyze_segmentation_map
¶
Analyzes a segmentation map to compute pixel counts and percentages for each category.
| PARAMETER | DESCRIPTION |
|---|---|
seg_map |
The segmentation map to analyze.
TYPE:
|
num_categories |
The total number of categories in the segmentation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[int, tuple[int, float]]
|
Dict[int, Tuple[int, float]]: A dictionary where keys are category IDs and values |
Dict[int, tuple[int, float]]
|
are tuples of (pixel count, percentage) for each category. |
Source code in cityseg/segmentation_analyzer.py
analyze_results
¶
Analyzes segmentation data and saves counts and percentages to CSV files.
This method processes the segmentation data in chunks, computes the analysis for each frame, and writes the results to separate CSV files for counts and percentages.
| PARAMETER | DESCRIPTION |
|---|---|
segmentation_data |
The segmentation data to analyze.
TYPE:
|
metadata |
Metadata containing label IDs and frame step.
TYPE:
|
output_path |
The path where the output CSV files will be saved.
TYPE:
|
Source code in cityseg/segmentation_analyzer.py
generate_category_stats
¶
Generates statistics for category counts or percentages.
This method reads the input CSV file, computes statistics (mean, median, std, min, max) for each category, and saves the results to the specified output file.
| PARAMETER | DESCRIPTION |
|---|---|
input_file |
Path to the input CSV file containing category data.
TYPE:
|
output_file |
Path to save the generated statistics.
TYPE:
|