←Select platform

Factor Property

Summary
Gets or sets the factor to be applied in the function operation specified in CurveType. This is a dependency property.
Syntax
C#
C++/CLI
public double Factor { get; set; } 
public: 
property double Factor { 
   double get(); 
   void set (    double ); 
} 

Property Value

The factor to be applied in the function operation specified in CurveType. Default value is 0.

Remarks

This parameter is used only if CurveType is CurveType.Exponential, CurveType.Logarithmic or CurveType.Sigmoid. If CurveType.Exponential or CurveType.Sigmoid is selected its value can be any value (+/-). If CurveType.Logarithmic is selected its value should be >= 0. If Factor = 0, the lookup table will be filled linearly.

Example
C#
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 viewer 
      using (RasterCodecs codecs = new RasterCodecs()) 
      { 
         theViewer.Image = codecs.Load(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Image3.dcm")); 
      } 
 
      // Create the sliders 
      TextBlock 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 effect 
      WindowLevelEffect effect = new WindowLevelEffect(); 
 
      // Set the texture 
      effect.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 properties 
      Binding 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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.1.23
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Media.Effects Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.