Пример #1
0
        /// <summary>Renders DICOM image to <see cref="IImage"/>.</summary>
        /// <param name="frame">Zero indexed frame number</param>
        /// <returns>Rendered image</returns>
        public virtual IImage RenderImage(int frame = 0)
        {
            if (frame != CurrentFrame || _pixelData == null)
            {
                Load(Dataset, frame);
            }

            var graphic = new ImageGraphic(_pixelData);

            if (ShowOverlays)
            {
                foreach (var overlay in _overlays)
                {
                    if ((frame + 1) < overlay.OriginFrame ||
                        (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1))
                    {
                        continue;
                    }

                    var og = new OverlayGraphic(
                        PixelDataFactory.Create(overlay),
                        overlay.OriginX - 1,
                        overlay.OriginY - 1,
                        OverlayColor);
                    graphic.AddOverlay(og);
                    og.Scale(this._scale);
                }
            }

            return(graphic.RenderImage(this._pipeline.LUT));
        }
Пример #2
0
        public virtual bool RenderImage(System.IO.MemoryStream ms, out int w, out int h, bool bRotate90 = false)
        {
            int frame = 0;

            if (frame != CurrentFrame || _pixelData == null)
            {
                Load(Dataset, frame);
            }

            var graphic = new ImageGraphic(_pixelData);

            if (ShowOverlays)
            {
                foreach (var overlay in _overlays)
                {
                    if ((frame + 1) < overlay.OriginFrame ||
                        (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1))
                    {
                        continue;
                    }

                    var og = new OverlayGraphic(
                        PixelDataFactory.Create(overlay),
                        overlay.OriginX - 1,
                        overlay.OriginY - 1,
                        OverlayColor);
                    graphic.AddOverlay(og);
                    og.Scale(this._scale);
                }
            }

            return(graphic.RenderImage(this._pipeline.LUT, ms, out w, out h, bRotate90));
        }
Пример #3
0
        /// <summary>Renders DICOM image to <see cref="IImage"/>.</summary>
        /// <param name="frame">Zero indexed frame number.</param>
        /// <returns>Rendered image</returns>
        public virtual IImage RenderImage(int frame = 0)
        {
            IPixelData pixels;

            lock (_lock)
            {
                var load = frame >= 0 && (frame != CurrentFrame || _rerender);
                CurrentFrame = frame;
                _rerender    = false;

                if (load)
                {
                    var frameIndex = GetFrameIndex(frame);
                    pixels  = PixelDataFactory.Create(_pixelData, frameIndex).Rescale(_scale);
                    _pixels = pixels;
                }
                else
                {
                    pixels = _pixels;
                }
            }

            if (ShowOverlays)
            {
                EstablishGraphicsOverlays();
            }

            IImage image;
            var    graphic = new ImageGraphic(pixels);

            if (ShowOverlays)
            {
                foreach (var overlay in _overlays)
                {
                    if (overlay.Data is EmptyBuffer)//fixed overlay.data is null, exception thrown
                    {
                        continue;
                    }

                    if (frame + 1 < overlay.OriginFrame ||
                        frame + 1 > overlay.OriginFrame + overlay.NumberOfFrames - 1)
                    {
                        continue;
                    }

                    var og = new OverlayGraphic(
                        PixelDataFactory.Create(overlay),
                        overlay.OriginX - 1,
                        overlay.OriginY - 1,
                        OverlayColor);
                    graphic.AddOverlay(og);
                    og.Scale(_scale);
                }
            }

            image = graphic.RenderImage(_pipeline.LUT);

            return(image);
        }
Пример #4
0
        /// <summary>Renders DICOM image to <see cref="IImage"/>.</summary>
        /// <param name="frame">Zero indexed frame number.</param>
        /// <returns>Rendered image</returns>
        public virtual IImage RenderImage(int frame = 0)
        {
            bool load;

            lock (_lock)
            {
                load          = frame >= 0 && (frame != CurrentFrame || _rerender);
                _currentFrame = frame;
                _rerender     = false;
            }

            var frameIndex = GetFrameIndex(frame);

            if (load)
            {
                lock (_lock)
                {
                    _pixels = PixelDataFactory.Create(_pixelData, frameIndex).Rescale(_scale);
                }
            }

            if (ShowOverlays)
            {
                EstablishGraphicsOverlays();
            }

            IImage image;

            lock (_lock)
            {
                var graphic = new ImageGraphic(_pixels);

                if (ShowOverlays)
                {
                    foreach (var overlay in _overlays)
                    {
                        if (frame + 1 < overlay.OriginFrame ||
                            frame + 1 > overlay.OriginFrame + overlay.NumberOfFrames - 1)
                        {
                            continue;
                        }

                        var og = new OverlayGraphic(
                            PixelDataFactory.Create(overlay),
                            overlay.OriginX - 1,
                            overlay.OriginY - 1,
                            OverlayColor);
                        graphic.AddOverlay(og);
                        og.Scale(_scale);
                    }
                }

                image = graphic.RenderImage(_pipeline.LUT);
            }

            return(image);
        }
Пример #5
0
		public ImageSource RenderImageSource() {
			ImageGraphic graphic = new ImageGraphic(_pixelData);

			foreach (var overlay in _overlays) {
				OverlayGraphic og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX, overlay.OriginY, OverlayColor);
				graphic.AddOverlay(og);
			}

			return graphic.RenderImageSource(_pipeline.LUT);
		}
Пример #6
0
        /// <summary>Renders DICOM image to System.Drawing.Image</summary>
        /// <returns>Rendered image</returns>
#if !SILVERLIGHT
        public Image RenderImage(Double resize = 0)
        {
            ImageGraphic graphic = new ImageGraphic(_pixelData, resize);

            foreach (var overlay in _overlays)
            {
                OverlayGraphic og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX, overlay.OriginY, OverlayColor);
                graphic.AddOverlay(og);
            }

            return(graphic.RenderImage(_pipeline.LUT));
        }
Пример #7
0
        /// <summary>Renders DICOM image to System.Drawing.Image</summary>
        /// <param name="frame">Zero indexed frame number</param>
        /// <returns>Rendered image</returns>
        public Image RenderImage(int frame = 0)
        {
            if (frame != _currentFrame || _pixelData == null)
            {
                Load(Dataset, frame);
            }

            ImageGraphic graphic = new ImageGraphic(_pixelData);

            foreach (var overlay in _overlays)
            {
                OverlayGraphic og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX, overlay.OriginY, OverlayColor);
                graphic.AddOverlay(og);
            }

            return(graphic.RenderImage(_pipeline.LUT));
        }
Пример #8
0
        public virtual bool  RenderImage(string saveToBmp, bool bRotate90 = false)
        {
            ImageGraphic graphic = null;

            try
            {
                int frame = 0;
                if (frame != CurrentFrame || _pixelData == null)
                {
                    Load(Dataset, frame);
                }

                graphic = new ImageGraphic(_pixelData);

                if (ShowOverlays)
                {
                    foreach (var overlay in _overlays)
                    {
                        if ((frame + 1) < overlay.OriginFrame ||
                            (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1))
                        {
                            continue;
                        }

                        var og = new OverlayGraphic(
                            PixelDataFactory.Create(overlay),
                            overlay.OriginX - 1,
                            overlay.OriginY - 1,
                            OverlayColor);
                        graphic.AddOverlay(og);
                        og.Scale(this._scale);
                    }
                }
                //return graphic.RenderImage(this._pipeline.LUT, bRotate90, saveToBmp);
                return(graphic.RenderFileImage(this._pipeline.LUT, saveToBmp));
            }
            finally
            {
                if (graphic != null)
                {
                    graphic = null;
                }
            }
            //RenderFileImage直接将像素数据输出到文件,无需内存中转以节约内存占用
        }
Пример #9
0
        /// <summary>Renders DICOM image to System.Drawing.Image</summary>
        /// <param name="frame">Zero indexed frame number</param>
        /// <returns>Rendered image</returns>
        public Image RenderImage(int frame = 0)
        {
            if (frame != _currentFrame || _pixelData == null)
            {
                Load(Dataset, frame);
            }

            var graphic = new ImageGraphic(_pixelData);

            try
            {
                if (ShowOverlays)
                {
                    foreach (var overlay in _overlays)
                    {
                        if ((frame + 1) < overlay.OriginFrame || (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1))
                        {
                            continue;
                        }

                        var og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX - 1, overlay.OriginY - 1, OverlayColor);
                        graphic.AddOverlay(og);
                        og.Scale(this._scale);
                    }
                }

                var image = graphic.RenderImage(_pipeline.LUT);

                return(new Bitmap(image));
            }
            finally
            {
                if (graphic != null)
                {
                    graphic.Dispose();
                }
            }
        }