LEADTOOLS WPF and Silverlight (Leadtools.Windows.Media.Effects assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
IntensityDetectEffect Class
See Also  Members  
Leadtools.Windows.Media.Effects Namespace : IntensityDetectEffect Class



The IntensityDetectEffect Class supports WPF/Silverlight.

Applies binary segmentation to an image by filtering the specified image to detect colors in a specified intensity range. Supported in Silverlight

Object Model

IntensityDetectEffect Class

Syntax

Visual Basic (Declaration) 
Public Class IntensityDetectEffect 
   Inherits System.Windows.Media.Effects.ShaderEffect
   Implements IAnimatable 
Visual Basic (Usage)Copy Code
Dim instance As IntensityDetectEffect
C# 
public class IntensityDetectEffect : System.Windows.Media.Effects.ShaderEffect, IAnimatable  
C++/CLI 
public ref class IntensityDetectEffect : public System.Windows.Media.Effects.ShaderEffect, IAnimatable  

Example

Visual BasicCopy Code
Class IntensityDetectEffectExampleWindow
      Inherits Window
      Public Sub New()
         Dim sp As New StackPanel()
         Content = sp
         Dim theViewer As New ImageViewer()

         theViewer.HorizontalAlignment = HorizontalAlignment.Center
         theViewer.VerticalAlignment = VerticalAlignment.Top
         theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left
         theViewer.ImageVerticalAlignment = VerticalAlignment.Top

         sp.Children.Add(theViewer)

         ' Create the sliders
         Dim tb As New TextBlock()
         tb.HorizontalAlignment = HorizontalAlignment.Center
         tb.Text = "Intensity:"
         sp.Children.Add(tb)

         Dim theSlider As New Slider()
         theSlider.Minimum = 0.0
         theSlider.Maximum = 256.0
         theSlider.Width = 400
         theSlider.Orientation = Orientation.Horizontal
         theSlider.IsSnapToTickEnabled = True
         theSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight
         theSlider.TickFrequency = 0.1
         theSlider.AutoToolTipPrecision = 2
         theSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight

         sp.Children.Add(theSlider)

         ' Load an image into the viewer
         theViewer.Source = New BitmapImage(New Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")))

         ' Create the effect
         Dim effect As New IntensityDetectEffect()
         effect.Intensity = 128.5
         theViewer.ImageEffect = effect

         ' Bind the properties
         Dim bind As New Binding()
         bind.Source = effect
         bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
         bind.Path = New PropertyPath("Intensity")
         theSlider.SetBinding(Slider.ValueProperty, bind)

         Title = "Using IntensityDetectEffect"
      End Sub
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
class IntensityDetectEffectExampleWindow : Window
   {
      public IntensityDetectEffectExampleWindow()
      {
         StackPanel sp = new StackPanel();
         Content = sp;
         ImageViewer theViewer = new ImageViewer();

         theViewer.HorizontalAlignment = HorizontalAlignment.Center;
         theViewer.VerticalAlignment = VerticalAlignment.Top;
         theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;
         theViewer.ImageVerticalAlignment = VerticalAlignment.Top;

         sp.Children.Add(theViewer);

         // Create the sliders
         TextBlock tb = new TextBlock();
         tb.HorizontalAlignment = HorizontalAlignment.Center;
         tb.Text = "Intensity:";
         sp.Children.Add(tb);

         Slider theSlider = new Slider();
         theSlider.Minimum = 0.0;
         theSlider.Maximum = 256.0;
         theSlider.Width = 400;
         theSlider.Orientation = Orientation.Horizontal;
         theSlider.IsSnapToTickEnabled = true;
         theSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;
         theSlider.TickFrequency = 0.1;
         theSlider.AutoToolTipPrecision = 2;
         theSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight;

         sp.Children.Add(theSlider);

         // Load an image into the viewer
         theViewer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")));

         // Create the effect
         IntensityDetectEffect effect = new IntensityDetectEffect();
         effect.Intensity = 128.5;
         theViewer.ImageEffect = effect;

         // Bind the properties
         Binding bind = new Binding();
         bind.Source = effect;
         bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
         bind.Path = new PropertyPath("Intensity");
         theSlider.SetBinding(Slider.ValueProperty, bind);

         Title = "Using IntensityDetectEffect";
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
class IntensityDetectEffectExampleWindow : UserControl
{
   public IntensityDetectEffectExampleWindow()
   {
      StackPanel sp = new StackPanel();
      Content = sp;
      ImageViewer theViewer = new ImageViewer();

      theViewer.HorizontalAlignment = HorizontalAlignment.Center;
      theViewer.VerticalAlignment = VerticalAlignment.Top;
      theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;
      theViewer.ImageVerticalAlignment = VerticalAlignment.Top;

      sp.Children.Add(theViewer);

      // Create the sliders
      TextBlock tb = new TextBlock();
      tb.HorizontalAlignment = HorizontalAlignment.Center;
      tb.Text = "Intensity:";
      sp.Children.Add(tb);

      Slider theSlider = new Slider();
      theSlider.Minimum = 0.0;
      theSlider.Maximum = 256.0;
      theSlider.Width = 400;
      theSlider.Orientation = Orientation.Horizontal;

      sp.Children.Add(theSlider);

      // Load an image into the viewer
      theViewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"));

      // Create the effect
      IntensityDetectEffect effect = new IntensityDetectEffect();
      effect.Intensity = 128.5;
      theViewer.ImageEffect = effect;

      // Bind the properties
      Binding bind = new Binding();
      bind.Source = effect;
      bind.UpdateSourceTrigger = UpdateSourceTrigger.Default;
      bind.Path = new PropertyPath("Intensity");
      theSlider.SetBinding(Slider.ValueProperty, bind);
   }
}
SilverlightVBCopy Code
Class IntensityDetectEffectExampleWindow
   Inherits UserControl
   Public Sub New()
      Dim sp As New StackPanel()
      Content = sp
      Dim theViewer As New ImageViewer()

      theViewer.HorizontalAlignment = HorizontalAlignment.Center
      theViewer.VerticalAlignment = VerticalAlignment.Top
      theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left
      theViewer.ImageVerticalAlignment = VerticalAlignment.Top

      sp.Children.Add(theViewer)

      ' Create the sliders
      Dim tb As New TextBlock()
      tb.HorizontalAlignment = HorizontalAlignment.Center
      tb.Text = "Intensity:"
      sp.Children.Add(tb)

      Dim theSlider As New Slider()
      theSlider.Minimum = 0.0
      theSlider.Maximum = 256.0
      theSlider.Width = 400
      theSlider.Orientation = Orientation.Horizontal

      sp.Children.Add(theSlider)

      ' Load an image into the viewer
      theViewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"))

      ' Create the effect
      Dim effect As New IntensityDetectEffect()
      effect.Intensity = 128.5
      theViewer.ImageEffect = effect

      ' Bind the properties
      Dim bind As New Binding()
      bind.Source = effect
      bind.UpdateSourceTrigger = UpdateSourceTrigger.Default
      bind.Path = New PropertyPath("Intensity")
      theSlider.SetBinding(Slider.ValueProperty, bind)
   End Sub
End Class
XAMLCopy Code
<Window x:Class="IntensityDetectEffectExample" Height="600" Width="800" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:leadControls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls" xmlns:leadEffects="clr-namespace:Leadtools.Windows.Media.Effects;assembly=Leadtools.Windows.Media.Effects">
  <StackPanel>
    <leadControls:ImageViewer HorizontalAlignment="Center" VerticalAlignment="Top" ImageHorizontalAlignment="Left" ImageVerticalAlignment="Top" Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg">
      <leadControls:ImageViewer.ImageEffect>
        <leadEffects:IntensityDetectEffect Intensity="{Binding Value, ElementName=IntensitySlider, UpdateSourceTrigger=PropertyChanged}"></leadEffects:IntensityDetectEffect>
      </leadControls:ImageViewer.ImageEffect>
    </leadControls:ImageViewer>
    <TextBlock HorizontalAlignment="Center" Text="Intensity:" />
    <Slider x:Name="IntensitySlider" Minimum="0.0" Maximum="256.0" TickFrequency="10" Width="400" Orientation="Horizontal" IsSnapToTickEnabled="True" TickPlacement="BottomRight" AutoToolTipPrecision="2" AutoToolTipPlacement="BottomRight"></Slider>
  </StackPanel>
</Window>

Remarks

This effect converts the image to a black and white, based on the threshold Intensity. Values less than Intensity are set to black while values larger than Intensity are set to white.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Freezable
            System.Windows.Media.Animation.Animatable
               System.Windows.Media.Effects.Effect
                  System.Windows.Media.Effects.ShaderEffect
                     Leadtools.Windows.Media.Effects.IntensityDetectEffect

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also