public override void Apply(IPresentationImage presentationImage) { if (!AppliesTo(presentationImage)) { throw new InvalidOperationException("The input presentation image is not supported."); } IVoiLutManager manager = ((IVoiLutProvider)presentationImage).VoiLutManager; IVoiLut currentLut = manager.VoiLut; if (currentLut is MinMaxPixelCalculatedLinearLut) { return; } GrayscalePixelData pixelData = (GrayscalePixelData)((IImageGraphicProvider)presentationImage).ImageGraphic.PixelData; IModalityLutProvider modalityLutProvider = presentationImage as IModalityLutProvider; if (modalityLutProvider != null) { manager.InstallVoiLut(new MinMaxPixelCalculatedLinearLut(pixelData, modalityLutProvider.ModalityLut)); } else { manager.InstallVoiLut(new MinMaxPixelCalculatedLinearLut(pixelData)); } }
private void SetWindow(double windowWidth, double windowCenter, out IBasicVoiLutLinear voiLut) { voiLut = null; if (!CanWindowLevel()) { return; } IVoiLutManager manager = SelectedVoiLutProvider.VoiLutManager; var linearLut = manager.VoiLut as IVoiLutLinear; var standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { standardLut = new BasicVoiLutLinear(windowWidth, windowCenter); manager.InstallVoiLut(standardLut); } else { standardLut.WindowWidth = windowWidth; standardLut.WindowCenter = windowCenter; } voiLut = standardLut; SelectedVoiLutProvider.Draw(); }
public override bool Track(IMouseInformation mouseInformation) { base.Track(mouseInformation); IVoiLutManager manager = SelectedVoiLutProvider.VoiLutManager; IVoiLutLinear linearLut = manager.VoiLut as IVoiLutLinear; IBasicVoiLutLinear standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { BasicVoiLutLinear installLut = new BasicVoiLutLinear(linearLut.WindowWidth, linearLut.WindowCenter); manager.InstallVoiLut(installLut); } standardLut = manager.VoiLut as IBasicVoiLutLinear; double sensitivity = CurrentSensitivity; if ((Math.Abs(standardLut.WindowCenter) + Math.Abs(standardLut.WindowWidth)) < 1000) { sensitivity = 1.0; } IncrementWindow(DeltaX * sensitivity, DeltaY * sensitivity); return(true); }
private static Bitmap DrawLutFrame(Frame f, double ww, double wc) { IPresentationImage pres = PresentationImageFactory.Create(f); IVoiLutProvider provider = ((IVoiLutProvider)pres); IVoiLutManager manager = provider.VoiLutManager; var linearLut = manager.VoiLut as IVoiLutLinear; if (linearLut != null) { var standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { var installLut = new BasicVoiLutLinear(ww, wc); manager.InstallVoiLut(installLut); } else { standardLut.WindowWidth = ww; standardLut.WindowCenter = wc; } provider.Draw(); } try { var bmp = pres.DrawToBitmap(f.Columns, f.Rows); if (f.Columns == f.Rows) { if (f.Columns < 512) { bmp = ResizeBitmap(bmp, 512, 512); } } return(bmp); } catch { return(null); } }
private void IncrementWindow(double windowIncrement, double levelIncrement) { if (!CanWindowLevel()) { return; } IVoiLutManager manager = SelectedVoiLutProvider.VoiLutManager; IVoiLutLinear linearLut = manager.VoiLut as IVoiLutLinear; IBasicVoiLutLinear standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { BasicVoiLutLinear installLut = new BasicVoiLutLinear(linearLut.WindowWidth, linearLut.WindowCenter); manager.InstallVoiLut(installLut); } standardLut = manager.VoiLut as IBasicVoiLutLinear; standardLut.WindowWidth += windowIncrement; standardLut.WindowCenter += levelIncrement; SelectedVoiLutProvider.Draw(); }