Leadtools.Windows.Media.Effects Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.02.15
UnsharpMaskCommandBitmapEffect Class
See Also  Members   Example 
Leadtools.Windows.Media.Effects.Effects Namespace : UnsharpMaskCommandBitmapEffect Class





Sharpens the image by applying the unsharp mask.

Syntax

Visual Basic (Declaration) 
Public Class UnsharpMaskCommandBitmapEffect 
   Inherits RasterCommandBitmapEffect
Visual Basic (Usage)Copy Code
Dim instance As UnsharpMaskCommandBitmapEffect
C# 
public class UnsharpMaskCommandBitmapEffect : RasterCommandBitmapEffect 
Managed Extensions for C++ 
public __gc class UnsharpMaskCommandBitmapEffect : public RasterCommandBitmapEffect 
C++/CLI 
public ref class UnsharpMaskCommandBitmapEffect : public RasterCommandBitmapEffect 
XAML Property Element Usage 

UnsharpMaskCommandBitmapEffect ...

Example

Run the UnsharpMaskCommandBitmapEffect on an image.

Visual BasicCopy Code
Public Sub UnsharpMaskCommandBitmapEffectExample(ByVal element As FrameworkElement)
   Dim effect As UnsharpMaskCommandBitmapEffect = New UnsharpMaskCommandBitmapEffect()
   effect.Amount = 200
   effect.Radius = 15
   effect.Threshold = 50
   effect.ColorType = UnsharpMaskCommandBitmapEffectsColorType.Rgb
   element.BitmapEffect = effect

   Dim storyboard As Storyboard = New Storyboard()

   Dim animation1 As Int32Animation = New Int32Animation()
   animation1.From = 1
   animation1.To = 100
   animation1.Duration = New Duration(TimeSpan.Parse("0:0:5"))
   animation1.RepeatBehavior = RepeatBehavior.Forever
   animation1.AutoReverse = True

   storyboard.SetTargetName(animation1, "AnimatedBitmapEffect")
   storyboard.SetTargetProperty(animation1, New PropertyPath(UnsharpMaskCommandBitmapEffect.RadiusProperty))
   element.RegisterName("AnimatedBitmapEffect", effect)
   storyboard.Children.Add(animation1)

   storyboard.Begin(element)
End Sub
C#Copy Code
public void UnsharpMaskCommandBitmapEffectExample(FrameworkElement element) 

   UnsharpMaskCommandBitmapEffect effect = new UnsharpMaskCommandBitmapEffect(); 
   effect.Amount = 200; 
   effect.Radius = 15; 
   effect.Threshold = 50; 
   effect.ColorType = UnsharpMaskCommandBitmapEffectsColorType.Rgb; 
   element.BitmapEffect = effect; 
 
   Storyboard storyboard = new Storyboard(); 
 
   Int32Animation animation1 = new Int32Animation(); 
   animation1.From = 1; 
   animation1.To = 100; 
   animation1.Duration = new Duration(TimeSpan.Parse("0:0:5")); 
   animation1.RepeatBehavior = RepeatBehavior.Forever; 
   animation1.AutoReverse = true; 
 
   Storyboard.SetTargetName(animation1, "AnimatedBitmapEffect"); 
   Storyboard.SetTargetProperty(animation1, new PropertyPath(UnsharpMaskCommandBitmapEffect.RadiusProperty)); 
   element.RegisterName("AnimatedBitmapEffect", effect); 
   storyboard.Children.Add(animation1); 
 
   storyboard.Begin(element); 
}
XAMLCopy Code
<Page Title="CSAnimateEffect" Height="391" Width="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lteffects="clr-namespace:Leadtools.Windows.Media.Effects.Effects;assembly=Leadtools.Windows.Media.Effects"> 
  <Grid> 
    <Image Margin="10,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Center" Source="C:\Program Files\LEAD Technologies, Inc\LEADTOOLS 15\Images\slave.jpg"> 
      <Image.BitmapEffect> 
        <lteffects:UnsharpMaskCommandBitmapEffect x:Name="AnimatedBitmapEffect" Amount="100" ColorType="Yuv" Threshold="0" /> 
      </Image.BitmapEffect> 
      <Image.Triggers> 
        <EventTrigger RoutedEvent="Image.Loaded"> 
          <BeginStoryboard> 
            <Storyboard> 
              <Int32Animation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="Radius" From="1" To="100" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="true" /> 
            </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
      </Image.Triggers> 
    </Image> 
  </Grid> 
</Page>

Remarks

  • This command is actually considered a sharpening method. It is used to sharpen the image with a minimum of noise. To reduce the noise, it starts by blurring a copy of the original image. The amount of blur depends on Radius. The method then determines the difference between each pixel's value of the original image and the corresponding pixel's value in the blurred image. If the difference is greater than the threshold value, then the difference between the pixel values is multiplied by the amount value and added to the original pixel value.
  • To increase the thickness of the sharpened edges, increase the radius value.
  • To increase the amount of sharpness, increase the amount value.
  • To reduce the noise and eliminate the small edges or individual pixels that will produce noise in image, increase the threshold value.
  • Using the Yuv color space decreases the processing time.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Freezable
            System.Windows.Media.Animation.Animatable
               System.Windows.Media.Effects.BitmapEffect
                  Leadtools.Windows.Media.Effects.RasterCommandBitmapEffect
                     Leadtools.Windows.Media.Effects.Effects.UnsharpMaskCommandBitmapEffect

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003

See Also