Fills and applies window leveling on the specified image.
public class WindowLevelEffect : System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatablePublic Class WindowLevelEffectInherits System.Windows.Media.Effects.ShaderEffectImplements System.Windows.Media.Animation.IAnimatable
public ref class WindowLevelEffect : public System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatableProvides "on demand" window-leveling as an effect and does not alter the image data.
To learn more about window-leveling, refer to RasterImage.WindowLevel, RasterImage.WindowLevelExt, WindowLevelCommand, Leadtools.ImageProcessing.Core.WindowLevelExtCommand, Saving Window-Leveled Images , and Changing Brightness and Contrast.
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.Windows.ControlsImports Leadtools.Windows.MediaImports Leadtools.Windows.Media.EffectsClass WindowLevelEffectExampleWindowInherits WindowPublic Sub New()Dim sp As New StackPanel()Content = spDim theViewer As New RasterImageViewer()theViewer.HorizontalAlignment = HorizontalAlignment.CentertheViewer.VerticalAlignment = VerticalAlignment.ToptheViewer.ImageHorizontalAlignment = HorizontalAlignment.LefttheViewer.ImageVerticalAlignment = VerticalAlignment.Topsp.Children.Add(theViewer)' Load an image into the viewerUsing codecs As New RasterCodecs()theViewer.Image = codecs.Load(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Image3.dcm"))End Using' Create the slidersDim tb As New TextBlock()tb.HorizontalAlignment = HorizontalAlignment.Centertb.Text = "Window Width:"sp.Children.Add(tb)Dim windowWidthSlider As New Slider()windowWidthSlider.Minimum = 0.0windowWidthSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1)windowWidthSlider.Width = 400windowWidthSlider.Orientation = Orientation.HorizontalwindowWidthSlider.IsSnapToTickEnabled = TruewindowWidthSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRightwindowWidthSlider.TickFrequency = 0.1windowWidthSlider.AutoToolTipPrecision = 2windowWidthSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRightsp.Children.Add(windowWidthSlider)tb = New TextBlock()tb.HorizontalAlignment = HorizontalAlignment.Centertb.Text = "Window Center:"sp.Children.Add(tb)Dim windowCenterSlider As New Slider()windowCenterSlider.Minimum = 0.0windowCenterSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1)windowCenterSlider.Width = 400windowCenterSlider.Orientation = Orientation.HorizontalwindowCenterSlider.IsSnapToTickEnabled = TruewindowCenterSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRightwindowCenterSlider.TickFrequency = 0.1windowCenterSlider.AutoToolTipPrecision = 2windowCenterSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRightsp.Children.Add(windowCenterSlider)' Setup the effectDim effect As New WindowLevelEffect()' Set the textureeffect.FillGrayTexture(theViewer.Image)effect.Start = Colors.Blackeffect.End = Colors.Whiteeffect.CurveType = CurveType.Lineareffect.Factor = 0.0effect.WindowWidth = Math.Pow(2, theViewer.Image.MaxValue - theViewer.Image.MinValue)effect.WindowCenter = effect.WindowWidth / 2theViewer.ImageEffect = effect' Bind the propertiesDim bind As New Binding()bind.Source = effectbind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChangedbind.Path = New PropertyPath("WindowWidth")windowWidthSlider.SetBinding(Slider.ValueProperty, bind)bind = New Binding()bind.Source = effectbind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChangedbind.Path = New PropertyPath("WindowCenter")windowCenterSlider.SetBinding(Slider.ValueProperty, bind)Title = "Using WindowLevelEffect"End SubEnd ClassPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Windows.Controls;using Leadtools.Windows.Media;using Leadtools.Windows.Media.Effects;class WindowLevelEffectExampleWindow : Window{public WindowLevelEffectExampleWindow(){StackPanel sp = new StackPanel();Content = sp;RasterImageViewer theViewer = new RasterImageViewer();theViewer.HorizontalAlignment = HorizontalAlignment.Center;theViewer.VerticalAlignment = VerticalAlignment.Top;theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;theViewer.ImageVerticalAlignment = VerticalAlignment.Top;sp.Children.Add(theViewer);// Load an image into the viewerusing(RasterCodecs codecs = new RasterCodecs()){theViewer.Image = codecs.Load(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Image3.dcm"));}// Create the slidersTextBlock tb = new TextBlock();tb.HorizontalAlignment = HorizontalAlignment.Center;tb.Text = "Window Width:";sp.Children.Add(tb);Slider windowWidthSlider = new Slider();windowWidthSlider.Minimum = 0.0;windowWidthSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1);windowWidthSlider.Width = 400;windowWidthSlider.Orientation = Orientation.Horizontal;windowWidthSlider.IsSnapToTickEnabled = true;windowWidthSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;windowWidthSlider.TickFrequency = 0.1;windowWidthSlider.AutoToolTipPrecision = 2;windowWidthSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight;sp.Children.Add(windowWidthSlider);tb = new TextBlock();tb.HorizontalAlignment = HorizontalAlignment.Center;tb.Text = "Window Center:";sp.Children.Add(tb);Slider windowCenterSlider = new Slider();windowCenterSlider.Minimum = 0.0;windowCenterSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1);windowCenterSlider.Width = 400;windowCenterSlider.Orientation = Orientation.Horizontal;windowCenterSlider.IsSnapToTickEnabled = true;windowCenterSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;windowCenterSlider.TickFrequency = 0.1;windowCenterSlider.AutoToolTipPrecision = 2;windowCenterSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight;sp.Children.Add(windowCenterSlider);// Setup the effectWindowLevelEffect effect = new WindowLevelEffect();// Set the textureeffect.FillGrayTexture(theViewer.Image);effect.Start = Colors.Black;effect.End = Colors.White;effect.CurveType = CurveType.Linear;effect.Factor = 0.0;effect.WindowWidth = Math.Pow(2, theViewer.Image.MaxValue - theViewer.Image.MinValue);effect.WindowCenter = effect.WindowWidth / 2;theViewer.ImageEffect = effect;// Bind the propertiesBinding bind = new Binding();bind.Source = effect;bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;bind.Path = new PropertyPath("WindowWidth");windowWidthSlider.SetBinding(Slider.ValueProperty, bind);bind = new Binding();bind.Source = effect;bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;bind.Path = new PropertyPath("WindowCenter");windowCenterSlider.SetBinding(Slider.ValueProperty, bind);Title = "Using WindowLevelEffect";}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Windows.Media;using Leadtools.Windows.Media.Effects;using Leadtools.Windows.Controls;class WindowLevelEffectExampleWindow : UserControl{public WindowLevelEffectExampleWindow(){StackPanel sp = new StackPanel();Content = sp;RasterImageViewer theViewer = new RasterImageViewer();theViewer.HorizontalAlignment = HorizontalAlignment.Center;theViewer.VerticalAlignment = VerticalAlignment.Top;theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;theViewer.ImageVerticalAlignment = VerticalAlignment.Top;sp.Children.Add(theViewer);// Load an image into the viewer//using(RasterCodecs codecs = new RasterCodecs()){RasterCodecs codecs = new RasterCodecs();theViewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image3.dcm");}// Create the slidersTextBlock tb = new TextBlock();tb.HorizontalAlignment = HorizontalAlignment.Center;tb.Text = "Window Width:";sp.Children.Add(tb);Slider windowWidthSlider = new Slider();windowWidthSlider.Minimum = 0.0;windowWidthSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1);windowWidthSlider.Width = 400;windowWidthSlider.Orientation = Orientation.Horizontal;sp.Children.Add(windowWidthSlider);tb = new TextBlock();tb.HorizontalAlignment = HorizontalAlignment.Center;tb.Text = "Window Center:";sp.Children.Add(tb);Slider windowCenterSlider = new Slider();windowCenterSlider.Minimum = 0.0;windowCenterSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1);windowCenterSlider.Width = 400;windowCenterSlider.Orientation = Orientation.Horizontal;sp.Children.Add(windowCenterSlider);// Setup the effectWindowLevelEffect effect = new WindowLevelEffect();// Set the textureeffect.FillGrayTexture(theViewer.Image);effect.Start = Colors.Black;effect.End = Colors.White;effect.CurveType = CurveType.Linear;effect.Factor = 0.0;effect.WindowWidth = Math.Pow(2, theViewer.Image.MaxValue - theViewer.Image.MinValue);effect.WindowCenter = effect.WindowWidth / 2;theViewer.ImageEffect = effect;// Bind the propertiesBinding bind = new Binding();bind.Source = effect;bind.UpdateSourceTrigger = UpdateSourceTrigger.Default;bind.Path = new PropertyPath("WindowWidth");windowWidthSlider.SetBinding(Slider.ValueProperty, bind);bind = new Binding();bind.Source = effect;bind.UpdateSourceTrigger = UpdateSourceTrigger.Default;bind.Path = new PropertyPath("WindowCenter");windowCenterSlider.SetBinding(Slider.ValueProperty, bind);}}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.Windows.ControlsImports Leadtools.Windows.MediaImports Leadtools.Windows.Media.EffectsClass WindowLevelEffectExampleWindowInherits UserControlPublic Sub New()Dim sp As New StackPanel()Content = spDim theViewer As New RasterImageViewer()theViewer.HorizontalAlignment = HorizontalAlignment.CentertheViewer.VerticalAlignment = VerticalAlignment.ToptheViewer.ImageHorizontalAlignment = HorizontalAlignment.LefttheViewer.ImageVerticalAlignment = VerticalAlignment.Topsp.Children.Add(theViewer)' Load an image into the viewerDim codecs As New RasterCodecs()theViewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image3.dcm")' Create the slidersDim tb As New TextBlock()tb.HorizontalAlignment = HorizontalAlignment.Centertb.Text = "Window Width:"sp.Children.Add(tb)Dim windowWidthSlider As New Slider()windowWidthSlider.Minimum = 0.0windowWidthSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1)windowWidthSlider.Width = 400windowWidthSlider.Orientation = Orientation.Horizontalsp.Children.Add(windowWidthSlider)tb = New TextBlock()tb.HorizontalAlignment = HorizontalAlignment.Centertb.Text = "Window Center:"sp.Children.Add(tb)Dim windowCenterSlider As New Slider()windowCenterSlider.Minimum = 0.0windowCenterSlider.Maximum = Math.Pow(2, theViewer.Image.BitsPerPixel - 1)windowCenterSlider.Width = 400windowCenterSlider.Orientation = Orientation.Horizontalsp.Children.Add(windowCenterSlider)' Setup the effectDim effect As New WindowLevelEffect()' Set the textureeffect.FillGrayTexture(theViewer.Image)effect.Start = Colors.Blackeffect.End = Colors.Whiteeffect.CurveType = CurveType.Lineareffect.Factor = 0.0effect.WindowWidth = Math.Pow(2, theViewer.Image.MaxValue - theViewer.Image.MinValue)effect.WindowCenter = effect.WindowWidth / 2theViewer.ImageEffect = effect' Bind the propertiesDim bind As New Binding()bind.Source = effectbind.UpdateSourceTrigger = UpdateSourceTrigger.Defaultbind.Path = New PropertyPath("WindowWidth")windowWidthSlider.SetBinding(Slider.ValueProperty, bind)bind = New Binding()bind.Source = effectbind.UpdateSourceTrigger = UpdateSourceTrigger.Defaultbind.Path = New PropertyPath("WindowCenter")windowCenterSlider.SetBinding(Slider.ValueProperty, bind)End SubEnd Class
|
Products |
Support |
Feedback: WindowLevelEffect Class - Leadtools.Windows.Media.Effects |
Introduction |
Help Version 19.0.2017.3.21
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.