Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mlavik1 committed Sep 8, 2024
1 parent ba9aa7c commit 07c42f0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Assets/Scripts/VolumeObject/VolumeRenderedObject.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using openDicom.Encoding;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -160,29 +161,28 @@ public void AddSegmentation(VolumeDataset dataset)
overlayType = OverlayType.Segmentation;

int lastSegmentationId = segmentationLabels.Count > 0 ? segmentationLabels.Max(l => l.id) : 0;
int maxSegmentationId = -1;
int minSegmentationId = int.MaxValue;
int maxSegmentationId = int.MinValue;

if (segmentationLabels.Count == 0)
{
secondaryDataset = dataset;
maxSegmentationId = Mathf.RoundToInt(dataset.GetMaxDataValue());
}
else
for (int i = 0; i < dataset.data.Length; i++)
{
for (int i = 0; i < dataset.data.Length; i++)
int value = Mathf.RoundToInt(dataset.data[i]);
if (value > 0)
{
int value = Mathf.RoundToInt(dataset.data[i]);
if (value > 0)
{
maxSegmentationId = Mathf.Max(maxSegmentationId, value);
secondaryDataset.data[i] = maxSegmentationId + value;
}
minSegmentationId = Mathf.Min(minSegmentationId, value);
maxSegmentationId = Mathf.Max(maxSegmentationId, value);
secondaryDataset.data[i] = lastSegmentationId + value;
}
secondaryDataset.RecalculateBounds();
secondaryDataset.RecreateDataTexture();
secondaryDataset.GetDataTexture().filterMode = FilterMode.Point;
}
for (int i = 1; i <= maxSegmentationId; i++)
secondaryDataset.RecalculateBounds();
secondaryDataset.RecreateDataTexture();
secondaryDataset.GetDataTexture().filterMode = FilterMode.Point;

for (int i = minSegmentationId; i <= maxSegmentationId; i++)
{
int segmentationId = i + lastSegmentationId;
SegmentationLabel segmentationLabel = new SegmentationLabel();
Expand Down

0 comments on commit 07c42f0

Please sign in to comment.