示例#1
0
        public void SaveSegmentationAs(SegmenterImageStackSaveDescription segmenterImageStackSaveDescription)
        {
            CommitSegmentation();

            var colorMapDataStream =
                new DataStream(
                    Interop.VolumeDescription.NumVoxelsX * Interop.VolumeDescription.NumVoxelsY * Interop.VolumeDescription.NumVoxelsZ * NUM_BYTES_PER_COLOR_MAP_PIXEL,
                    true,
                    true);
            var idMapDataStream =
                new DataStream(
                    Interop.VolumeDescription.NumVoxelsX * Interop.VolumeDescription.NumVoxelsY * Interop.VolumeDescription.NumVoxelsZ * NUM_BYTES_PER_COLOR_MAP_PIXEL,
                    true,
                    true);

            var volumeDescriptions = new Dictionary <VolumeDescription>
            {
                {
                    "ColorMap", new VolumeDescription
                    {
                        DxgiFormat       = Format.R8G8B8A8_UNorm,
                        DataStream       = colorMapDataStream,
                        Data             = colorMapDataStream.DataPointer,
                        NumBytesPerVoxel = NUM_BYTES_PER_COLOR_MAP_PIXEL,
                        NumVoxelsX       = Interop.VolumeDescription.NumVoxelsX,
                        NumVoxelsY       = Interop.VolumeDescription.NumVoxelsY,
                        NumVoxelsZ       = Interop.VolumeDescription.NumVoxelsZ,
                        IsSigned         = false
                    }
                },
                {
                    "IdMap", new VolumeDescription
                    {
                        DxgiFormat       = Format.R32_UInt,
                        DataStream       = idMapDataStream,
                        Data             = idMapDataStream.DataPointer,
                        NumBytesPerVoxel = NUM_BYTES_PER_ID_MAP_PIXEL,
                        NumVoxelsX       = Interop.VolumeDescription.NumVoxelsX,
                        NumVoxelsY       = Interop.VolumeDescription.NumVoxelsY,
                        NumVoxelsZ       = Interop.VolumeDescription.NumVoxelsZ,
                        IsSigned         = false
                    }
                },
            };

            Interop.SaveSegmentationAs(volumeDescriptions);

            segmenterImageStackSaveDescription.VolumeDescriptions = volumeDescriptions;

            SegmenterImageStackLoader.SaveSegmentation(segmenterImageStackSaveDescription);
        }
示例#2
0
        public void LoadDataset(SegmenterImageStackLoadDescription segmenterImageStackLoadDescription)
        {
            var volumeDescriptions = SegmenterImageStackLoader.LoadDataset(segmenterImageStackLoadDescription);

            var neuralProcessDescriptions = new ObservableDictionary <int, NeuralProcessDescription>
            {
                { Constants.DEFAULT_NEURAL_PROCESS.Id, Constants.DEFAULT_NEURAL_PROCESS }
            };

            var datasetDescription = new DatasetDescription
            {
                NeuralProcessDescriptions = neuralProcessDescriptions,
                VolumeDescriptions        = volumeDescriptions
            };

            LoadDataset(datasetDescription);
        }
示例#3
0
        public void LoadDataset(SegmenterImageStackLoadDescription segmenterImageStackLoadDescription, BreadcrumbXmlLoadDescription breadcrumbXmlLoadDescription)
        {
            var volumeDescriptions = SegmenterImageStackLoader.LoadDataset(segmenterImageStackLoadDescription);

            var breadcrumbXmlLoader       = new BreadcrumbXmlLoader();
            var neuralProcessDescriptions = breadcrumbXmlLoader.LoadDataset(breadcrumbXmlLoadDescription);

            neuralProcessDescriptions.Add(Constants.DEFAULT_NEURAL_PROCESS.Id, Constants.DEFAULT_NEURAL_PROCESS);

            var datasetDescription = new DatasetDescription
            {
                NeuralProcessDescriptions = neuralProcessDescriptions,
                VolumeDescriptions        = volumeDescriptions
            };

            LoadDataset(datasetDescription);
        }
示例#4
0
        public void LoadSegmentation(SegmenterImageStackLoadDescription segmenterImageStackLoadDescription)
        {
            UnloadSegmentation();

            var volumeDescriptions = SegmenterImageStackLoader.LoadSegmentation(segmenterImageStackLoadDescription);

            Interop.LoadSegmentation(volumeDescriptions);
            Interop.VisualUpdate();
            Interop.VisualUpdateColorMap();

            volumeDescriptions.Get("ColorMap").DataStream.Seek(0, SeekOrigin.Begin);
            volumeDescriptions.Get("IdMap").DataStream.Seek(0, SeekOrigin.Begin);

            var uniqueIds = new Dictionary <int, Rgb>();

            for (var z = 0; z < volumeDescriptions.Get("IdMap").NumVoxelsZ; z++)
            {
                for (var y = 0; y < volumeDescriptions.Get("IdMap").NumVoxelsY; y++)
                {
                    for (var x = 0; x < volumeDescriptions.Get("IdMap").NumVoxelsX; x++)
                    {
                        var id            = volumeDescriptions.Get("IdMap").DataStream.Read <int>();
                        var colorMapValue = volumeDescriptions.Get("ColorMap").DataStream.Read <int>();

                        var r = (colorMapValue & (0x0000ff << 0)) >> 0;
                        var g = (colorMapValue & (0x0000ff << 8)) >> 8;
                        var b = (colorMapValue & (0x0000ff << 16)) >> 16;



                        if (id == 0)
                        {
                            if (!(r == 0 && g == 0 && b == 0))
                            {
                                Console.WriteLine("WARNING: x = {0}, y = {1}, z = {2}, id = {3}, color = {4}", x, y, z, id, new Rgb(r, g, b).ToString());
                            }
                        }

                        if (uniqueIds.ContainsKey(id))
                        {
                            if (!uniqueIds[id].Equals(new Rgb(r, g, b)))
                            {
                                Console.WriteLine("WARNING: x = {0}, y = {1}, z = {2}, id = {3}, existing color = {4}, new color = {5}", x, y, z, id, uniqueIds[id].ToString(), new Rgb(r, g, b).ToString());
                            }
                        }



                        if (!uniqueIds.ContainsKey(id))
                        {
                            uniqueIds[id] = new Rgb(r, g, b);
                        }
                    }
                }
            }

            uniqueIds.Remove(Constants.NULL_NEURAL_PROCESS.Id);

            uniqueIds.ToList().ForEach(keyValuePair =>
                                       DatasetDescription.NeuralProcessDescriptions.Add(keyValuePair.Key,
                                                                                        new NeuralProcessDescription(keyValuePair.Key)
            {
                Name  = "Autogenerated Neural Process (ID " + keyValuePair.Key + ") " + keyValuePair.Value,
                Color =
                    new Vector3((float)keyValuePair.Value.Red,
                                (float)keyValuePair.Value.Green,
                                (float)keyValuePair.Value.Blue),
                BreadcrumbDescriptions = new List <BreadcrumbDescription>()
            }));

            CurrentNeuralProcess                  = null;
            MergeSourceNeuralProcess              = null;
            MergeDestinationNeuralProcess         = null;
            SplitNeuralProcess                    = null;
            CommittedSegmentationEqualsUndoBuffer = false;
            CommittedSegmentationEqualsRedoBuffer = false;
            SegmentationLoaded                    = true;
        }