Exemple #1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            Image3D image;

            //string testPath = @"MANIX\CER-CT\ANGIO CT";
            //string testPath = @"BRAINIX\SOUS - 702";
            //string testPath = @"BRAINIX\T2W-FE-EPI - 501";
            string testPath = @"vtkBrain";

            double min, max;
            using (var reader = new DicomReader(TestData.GetPath(testPath)))
            {
                image = reader.ReadImage3D();

                min = reader.MinValue;
                max = reader.MaxValue;
            }

            display = new DisplayImage(image.LengthX, image.LengthY);

            var tf = new TransferFunction1D();
            tf.Add(0, Color.Black);
            tf.Add(max * 0.2, Color.Blue);
            tf.Add(max * 0.6, Color.Red);
            tf.Add(max, Color.Yellow);

            renderer = new TransferFunctionRenderer(image, display, tf);

            scrollBarSlice.Maximum = image.LengthZ - 1;
            pictureBoxDisplay.Image = display.GetBitmap();

            Render();
        }
Exemple #2
0
        protected override Image3D OnProcess(Image3D image, Progress progress)
        {
            if (cache == null)
            {
                if (!CombineFilesToSlices)
                {
                    using (var reader = new DicomReader(Path))
                    {
                        cache = reader.ReadImage3D(progress);
                        cache.Minimum = reader.MinValue;
                        cache.Maximum = reader.MaxValue;
                    }
                }
                else
                {
                    using (var reader = new FileToSliceDicomReader(Path))
                    {
                        cache = reader.ReadImage3D(progress);
                        cache.Minimum = reader.MinValue;
                        cache.Maximum = reader.MaxValue;
                    }
                }

                Log.I("Image loaded. min: " + cache.Minimum + "; max: " + cache.Maximum);
            }

            return cache;
        }
Exemple #3
0
        public Image3D ReadImage3D(Progress progress)
        {
            this.progress = progress;

            var directory = new DirectoryInfo(path);
            var files = directory.GetFiles();

            // TODO: remove (allow max 900 slices)
            if (files.Length > 900)
            {
                Array.Resize<FileInfo>(ref files, 900);
            }
            // ---

            Image3D slice0;
            using (var reader0 = new DicomReader(files[0].FullName))
            {
                slice0 = reader0.ReadImage3D(new Progress());
            }
            this.image = new Image3D(files.Length, slice0.LengthY, slice0.LengthX);
            this.image.CloneSlice(slice0, 0, 0);
            MinValue = Math.Min(MinValue, slice0.Minimum);
            MaxValue = Math.Max(MaxValue, slice0.Maximum);
            slice0 = null;
            slicesDone++;

            //ThreadPool.SetMaxThreads(8, 8);

            for (int z = 1; z < files.Length; z++)
            {
                ReadSlice(new SliceInfo(files[z], z));
                //ThreadPool.QueueUserWorkItem(new WaitCallback(ReadSlice), );
            }

            while (slicesDone != image.LengthZ)
            {
                Thread.Sleep(50);
            }

            progress.Done();

            path = null;
            return image;
        }
Exemple #4
0
        private void ReadSlice(object sliceInfoObj)
        {
            if (disposed) { return; }

            var info = (SliceInfo)sliceInfoObj;

            Image3D slice;
            using (var reader = new DicomReader(info.File.FullName))
            {
                slice = reader.ReadImage3D(new Progress());
            }

            var imageCopy = image; // is not null before disposed.
            if (disposed) { return; }

            imageCopy.CloneSlice(slice, 0, info.Index);

            lock (statusLockObject)
            {
                MinValue = Math.Min(MinValue, slice.Minimum);
                MaxValue = Math.Max(MaxValue, slice.Maximum);
                slicesDone++;
            }

            progress.UpdateIncrement((double)1.0 / image.LengthZ);
        }