Skip to content

Commit ce816fb

Browse files
committed
Don't show segmentation labels for unused segmentations
1 parent a441daf commit ce816fb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Assets/Scripts/Segmentation/SegmentationBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static List<SegmentationLabel> BuildSegmentations(VolumeDataset dataset)
3535
List<SegmentationLabel> result = new List<SegmentationLabel>();
3636
int minSegmentationId = int.MaxValue;
3737
int maxSegmentationId = int.MinValue;
38+
HashSet<int> usedSegmentationIds = new HashSet<int>();
3839

3940
for (int i = 0; i < dataset.data.Length; i++)
4041
{
@@ -43,13 +44,16 @@ public static List<SegmentationLabel> BuildSegmentations(VolumeDataset dataset)
4344
{
4445
minSegmentationId = Mathf.Min(minSegmentationId, value);
4546
maxSegmentationId = Mathf.Max(maxSegmentationId, value);
47+
usedSegmentationIds.Add(value);
4648
}
4749
}
4850

4951
bool multiLabel = maxSegmentationId - minSegmentationId > 1;
5052

5153
for (int segmentationId = minSegmentationId; segmentationId <= maxSegmentationId; segmentationId++)
5254
{
55+
if (!usedSegmentationIds.Contains(segmentationId))
56+
continue;
5357
SegmentationLabel segmentationLabel = new SegmentationLabel();
5458
segmentationLabel.id = segmentationId;
5559
segmentationLabel.name = dataset.datasetName;

0 commit comments

Comments
 (0)