/// <summary> /// Initialize new instance of <seealso cref="PaletteColorPipeline"/> containing palette color LUT extracted from /// <paramref name="pixelData"/> /// </summary> /// <param name="pixelData">Dicom Pixel Data containing paletter color LUT</param> public PaletteColorPipeline(DicomPixelData pixelData) { var lut = pixelData.PaletteColorLUT; var first = pixelData.Dataset.Get<int>(DicomTag.RedPaletteColorLookupTableDescriptor, 1); _lut = new PaletteColorLUT(first, lut); }
public PrecalculatedLUT(ILUT lut, int minValue, int maxValue) { _minValue = minValue; _maxValue = maxValue; _offset = -_minValue; _table = new int[_maxValue - _minValue + 1]; _lut = lut; }
public PrecalculatedLUT(ILUT lut) { _minValue = lut.MinimumOutputValue; _maxValue = lut.MaximumOutputValue; _offset = -_minValue; _table = new int[_maxValue - _minValue + 1]; _lut = lut; for (int i = _minValue; i <= _maxValue; i++) { _table[i + _offset] = _lut[i]; } }
public PrecalculatedLUT(int minValue, int maxValue, ILUT lut) { _minValue = minValue; _maxValue = maxValue; _offset = -_minValue; _table = new int[_maxValue - _minValue + 1]; _lut = lut; for (int i = _minValue; i <= _maxValue; i++) { _table[i + _offset] = _lut[i]; } }
public void Render(ILUT lut, int[] output) { if (lut == null) { Parallel.For(0, Height, y => { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = _data[i]; } }); } else { Parallel.For(0, Height, y => { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = lut[_data[i]]; } }); } }
public void Render(ILUT lut, int[] output) { if (lut == null) { Parallel.For(0, Height, y => { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = (_data[p++] << 16) | (_data[p++] << 8) | _data[p++]; } }); } else { Parallel.For(0, Height, y => { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = (lut[_data[p++]] << 16) | (lut[_data[p++]] << 8) | lut[_data[p++]]; } }); } }
/// <inheritdoc /> public void Render(ILUT lut, int[] output) { const int alphaFF = 0xff << 24; var data = Data; if (lut == null) { #if NET35 for (var y = 0; y < Height; ++y) #else Parallel.For(0, Height, y => #endif { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = alphaFF | (data[p++] << 16) | (data[p++] << 8) | data[p++]; } } #if !NET35 ); #endif } else { #if NET35 for (var y = 0; y < Height; ++y) #else Parallel.For(0, Height, y => #endif { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = alphaFF | (lut[data[p++]] << 16) | (lut[data[p++]] << 8) | lut[data[p++]]; } } #if !NET35 ); #endif } }
public BitmapSource RenderImageSource(ILUT lut) { var render = false; if (_bitmap == null) { _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); foreach (var overlay in _overlays) { overlay.Render(_pixels.Data, ScaledData.Width, ScaledData.Height); } } using ( var context = new CGBitmapContext(_pixels, ScaledWidth, ScaledHeight, 8, 4 * ScaledWidth, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedLast)) { var transform = CGAffineTransform.MakeRotation((float)(_rotation * Math.PI / 180.0)); transform.Scale(_flipX ? -1.0f : 1.0f, _flipY ? -1.0f : 1.0f); transform.Translate(_flipX ? ScaledWidth : 0.0f, _flipY ? ScaledHeight : 0.0f); context.ConcatCTM(transform); _bitmap = context.ToImage(); } return(_bitmap); }
public BitmapSource RenderImageSource(ILUT lut) { WriteableBitmap img = BackgroundLayer.RenderImageSource(lut) as WriteableBitmap; if (img != null && _layers.Count > 1) { for (int i = 1; i < _layers.Count; ++i) { var g = _layers[i]; var layer = _layers[i].RenderImageSource(null) as WriteableBitmap; if (layer != null) { Array pixels = new int[g.ScaledWidth * g.ScaledHeight]; layer.CopyPixels(pixels, 4, 0); img.WritePixels(new Int32Rect(g.ScaledOffsetX, g.ScaledOffsetY, g.ScaledWidth, g.ScaledHeight), pixels, 4, 0); } } } return(img); }
public IImage RenderImage(ILUT lut) { if (this._applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); } var image = ImageManager.CreateImage(this.ScaledWidth, this.ScaledHeight); var pixels = image.Pixels.Data; this.ScaledData.Render(this._applyLut ? lut : null, pixels); foreach (var overlay in this._overlays) { overlay.Render(pixels, this.ScaledWidth, this.ScaledHeight); } image.Render(this.Components, this._flipX, this._flipY, this._rotation); return(image); }
/// <inheritdoc /> public void Render(ILUT lut, int[] output) { var data = Data; if (lut == null) { #if NET35 for (var y = 0; y < Height; ++y) #else Parallel.For(0, Height, y => #endif { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = data[i]; } } #if !NET35 ); #endif } else { #if NET35 for (var y = 0; y < Height; ++y) #else Parallel.For(0, Height, y => #endif { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = lut[data[i]]; } } #if !NET35 ); #endif } }
public bool RenderFileImage(ILUT lut, string saveToBmp) { if (this._applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); } IFileImage image = null; try { image = FileImageManager.CreateImage(this.ScaledWidth, this.ScaledHeight, saveToBmp); var pixels = image.Pixels; this.ScaledData.RenderToStream(this._applyLut ? lut : null, pixels); foreach (var overlay in this._overlays) { //overlay.Render(pixels, this.ScaledWidth, this.ScaledHeight); //overlay未实现RenderToStream,目前测试的dcm均不含overlay throw new NotSupportedException(); } image.Flush(); return(true); } catch (Exception) { return(false); } finally { if (image != null) { image.Dispose(); image = null; } } }
public Image RenderImage(ILUT lut) { bool render = false; if (_bitmap == null) { System.Drawing.Imaging.PixelFormat format = Components == 4 ? System.Drawing.Imaging.PixelFormat.Format32bppArgb : System.Drawing.Imaging.PixelFormat.Format32bppRgb; _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); _bitmap = new Bitmap(ScaledData.Width, ScaledData.Height, ScaledData.Width * 4, format, _pixels.Pointer); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } _bitmap.RotateFlip(RotateFlipType.RotateNoneFlipNone); if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); foreach (var overlay in _overlays) { overlay.Render(_pixels.Data, ScaledData.Width, ScaledData.Height); } } _bitmap.RotateFlip(GetRotateFlipType()); return(_bitmap); }
public void Render(ILUT lut, int[] output) { #if NETFX_CORE || SILVERLIGHT const int opaqueAlpha = 0xff << 24; #else const int opaqueAlpha = 0; #endif if (lut == null) { Parallel.For(0, Height, y => { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = opaqueAlpha | (_data[p++] << 16) | (_data[p++] << 8) | _data[p++]; } }); } else { Parallel.For(0, Height, y => { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = opaqueAlpha | (lut[_data[p++]] << 16) | (lut[_data[p++]] << 8) | lut[_data[p++]]; } }); } }
public void Render(ILUT lut, int[] output) { if (lut == null) { MultiThread.For(0, Height, delegate(int y) { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = _data[i]; } }); } else { MultiThread.For(0, Height, delegate(int y) { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = lut[_data[i]]; } }); } }
public void Add(ILUT lut) => _luts.Add(lut);
public Image RenderImage(ILUT lut) { bool render = false; if (_bitmap == null) { PixelFormat format = Components == 4 ? PixelFormat.Format32bppArgb : PixelFormat.Format32bppRgb; _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); _bitmap = new Bitmap(ScaledData.Width, ScaledData.Height, ScaledData.Width * 4, format, _pixels.Pointer); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } _bitmap.RotateFlip(RotateFlipType.RotateNoneFlipNone); if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); } _bitmap.RotateFlip(GetRotateFlipType()); return _bitmap; }
public void Render(ILUT lut, int[] output) { if (lut == null) { MultiThread.For(0, Height, delegate(int y) { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = (_data[p++] << 16) | (_data[p++] << 8) | _data[p++]; } }); } else { MultiThread.For(0, Height, delegate(int y) { for (int i = Width * y, e = i + Width, p = i * 3; i < e; i++) { output[i] = (lut[_data[p++]] << 16) | (lut[_data[p++]] << 8) | lut[_data[p++]]; } }); } }
public void Render(ILUT lut, int[] output) { var data = Data; if (lut == null) { #if NET35 for (var y = 0; y < Height; ++y) #else Parallel.For(0, Height, y => #endif { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = data[i]; } } #if !NET35 ); #endif } else { #if NET35 for (var y = 0; y < Height; ++y) #else Parallel.For(0, Height, y => #endif { for (int i = Width * y, e = i + Width; i < e; i++) { output[i] = lut[data[i]]; } } #if !NET35 ); #endif } }
public IImage RenderImage(ILUT lut) { if (this._applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); } var image = ImageManager.CreateImage(this.ScaledWidth, this.ScaledHeight); var pixels = image.Pixels.Data; this.ScaledData.Render(this._applyLut ? lut : null, pixels); foreach (var overlay in this._overlays) { overlay.Render(pixels, this.ScaledWidth, this.ScaledHeight); } image.Render(this.Components, this._flipX, this._flipY, this._rotation); return image; }
public IImage RenderImage(ILUT lut) { var img = BackgroundLayer.RenderImage(lut); if (_layers.Count > 1) { img.DrawGraphics(_layers.Skip(1)); } return img; }
public void Add(ILUT lut) { _luts.Add(lut); }
public BitmapSource RenderImageSource(ILUT lut) { WriteableBitmap img = BackgroundLayer.RenderImageSource(lut) as WriteableBitmap; if (img != null && _layers.Count > 1) { for (int i = 1; i < _layers.Count; ++i) { var g = _layers[i]; var layer = _layers[i].RenderImageSource(null) as WriteableBitmap; if (layer != null) { Array pixels = new int[g.ScaledWidth * g.ScaledHeight]; layer.CopyPixels(pixels, 4, 0); img.WritePixels(new Int32Rect(g.ScaledOffsetX, g.ScaledOffsetY, g.ScaledWidth, g.ScaledHeight), pixels, 4, 0); } } } return img; }
public Image RenderImage(ILUT lut) { Image img = BackgroundLayer.RenderImage(lut); if (_layers.Count > 1) { using (Graphics graphics = Graphics.FromImage(img)) { for (int i = 1; i < _layers.Count; i++) { Image layer = _layers[i].RenderImage(null); graphics.DrawImage(layer, _layers[i].ScaledOffsetX, _layers[i].ScaledOffsetY); } } } return img; }
// Init public static void Init() { if (ConsoleVarManager.GetValueToString("Q2ConsoleInit") == "true") { // Init FreeGlut int[] argc = new int[1]; argc[0] = 0; string[] argv = null; FG.Init(argc, argv); FG.InitDisplayMode(FG.GLUT_RGBA | FG.GLUT_DOUBLE | FG.GLUT_DEPTH); FG.InitWindowPosition(25, 25); FG.InitWindowSize(1024, 768); FG.InitContextVersion(2, 1); FG.InitContextFlags((int)FG.GLUT_FORWARD_COMPATIBLE); FG.InitContextProfile((int)FG.GLUT_COMPATIBILITY_PROFILE); int hWindow = FG.CreateWindow(ConsoleVarManager.GetValueToString("VersionLong")); // Setup OpenGL window and OpenGL itself GL.Init(true); // Init DevIL -> Developers Image Libary IL.Init(); ILU.Init(); ILUT.Init(); ILUT.Renderer(ILUT.ILUT_OPENGL); } SetupGL(); // Each time ScreenSize changes, this must be called ConsoleManager.Init(); // Each time ScreenSize changes, this must be called if (ConsoleVarManager.GetValueToString("Q2ConsoleInit") == "true") { string[] OpenGLDotNetInitLog = GLConfig.LogDumpToString(); foreach (string Line in OpenGLDotNetInitLog) { ConsoleManager.WriteLine(Line); } } if (ConsoleVarManager.GetValueToString("Q2ConsoleInit") == "true") { // We don't want to Init and Add commands each time ScreenSize changes CommandManager.Init(); CommandManager.ExecuteCommand("openglinfo"); CommandManager.ExecuteCommand("cpuinfo"); CommandManager.ExecuteCommand("help"); FG.IdleFunc(IdleProc); FG.KeyboardFunc(KeyboardProc); FG.MouseFunc(MouseProc); FG.ReshapeFunc(ReshapeProc); FG.DisplayFunc(DisplayProc); GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); FG.SwapBuffers(); // Before entering FG.MainLoop(), we must set the variable ConsoleVarManager.Set("Q2ConsoleInit", "false"); // Enter the FG.MainLoop() FG.SetOption(FG.GLUT_ACTION_ON_WINDOW_CLOSE, (int)FG.GLUT_ACTION_GLUTMAINLOOP_RETURNS); FG.MainLoop(); } }
public LUTOverlay(ILUT lut, IVoxelDataStructure grid) { }
public BitmapSource RenderImageSource(ILUT lut) { WriteableBitmap img = BackgroundLayer.RenderImageSource(lut) as WriteableBitmap; if (img != null && _layers.Count > 1) { for (int i = 1; i < _layers.Count; ++i) { var g = _layers[i]; var layer = _layers[i].RenderImageSource(null) as WriteableBitmap; if (layer != null) { var rect = new Rect(g.ScaledOffsetX, g.ScaledOffsetY, g.ScaledWidth, g.ScaledHeight); img.Blit(rect, layer, rect); } } } return img; }
public BitmapSource RenderImageSource(ILUT lut) { var img = new MonoTouch.CoreGraphics.CGBitmapContext(IntPtr.Zero, OriginalWidth, OriginalHeight, 8, 4 * OriginalWidth, MonoTouch.CoreGraphics.CGColorSpace.CreateDeviceRGB(), MonoTouch.CoreGraphics.CGImageAlphaInfo.PremultipliedFirst); for (var i = 0; i < _layers.Count; ++i) { var g = _layers[i]; var layer = _layers[i].RenderImageSource(i == 0 ? lut : null); if (layer != null) { var rect = new System.Drawing.RectangleF(g.ScaledOffsetX, g.ScaledOffsetY, g.ScaledWidth, g.ScaledHeight); img.DrawImage(rect, layer); } } return img.ToImage(); }