Skip to content

Commit

Permalink
Don't show segmentation labels for unused segmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
mlavik1 committed Jan 29, 2025
1 parent a441daf commit ce816fb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Assets/Scripts/Segmentation/SegmentationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static List<SegmentationLabel> BuildSegmentations(VolumeDataset dataset)
List<SegmentationLabel> result = new List<SegmentationLabel>();
int minSegmentationId = int.MaxValue;
int maxSegmentationId = int.MinValue;
HashSet<int> usedSegmentationIds = new HashSet<int>();

for (int i = 0; i < dataset.data.Length; i++)
{
Expand All @@ -43,13 +44,16 @@ public static List<SegmentationLabel> BuildSegmentations(VolumeDataset dataset)
{
minSegmentationId = Mathf.Min(minSegmentationId, value);
maxSegmentationId = Mathf.Max(maxSegmentationId, value);
usedSegmentationIds.Add(value);
}
}

bool multiLabel = maxSegmentationId - minSegmentationId > 1;

for (int segmentationId = minSegmentationId; segmentationId <= maxSegmentationId; segmentationId++)
{
if (!usedSegmentationIds.Contains(segmentationId))
continue;
SegmentationLabel segmentationLabel = new SegmentationLabel();
segmentationLabel.id = segmentationId;
segmentationLabel.name = dataset.datasetName;
Expand Down

0 comments on commit ce816fb

Please sign in to comment.