LEADTOOLS Image Processing (Leadtools.ImageProcessing.Core assembly)

SliceCommand Class

Show in webframe
Example 







Members 
Extracts individual slices from a radiographic scanned film. This method is available in the Raster Pro and above toolkits.
Object Model
Syntax
'Declaration
 
Public Class SliceCommand 
   Inherits Leadtools.ImageProcessing.RasterCommand
   Implements Leadtools.ImageProcessing.IRasterCommand 
'Usage
 
Dim instance As SliceCommand
public sealed class SliceCommand : Leadtools.ImageProcessing.IRasterCommand  

            

            
function Leadtools.ImageProcessing.Core.SliceCommand()
Remarks
Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core

Public WithEvents sliceEventExample_S1 As SliceCommand
Public Sub SliceCommandExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"))

   ' Prepare the command
   Dim cmd As New SliceCommand
   cmd.FillColor = New RasterColor(0, 0, 0)
   cmd.MaximumDeskewAngle = 40
   cmd.Flags = SliceCommandFlags.Bicubic Or SliceCommandFlags.WithoutCut Or SliceCommandFlags.DeskewImage

   ' Apply the slice command on the image.
   cmd.Run(leadImage)

   ' Print out the deskew amount.
   Console.WriteLine("Deskew Angle = {0}", cmd.DeskewAngle)

End Sub

Private Sub SliceEventExample_SliceCommand(ByVal sender As Object, ByVal e As SliceCommandEventArgs) Handles sliceEventExample_S1.Slice
   ' create a region around the slice
   If (e.Image.HasRegion) Then
      e.Image.AddRectangleToRegion(Nothing, e.SliceRectangle, RasterRegionCombineMode.Xor)
   Else
      e.Image.AddRectangleToRegion(Nothing, e.SliceRectangle, RasterRegionCombineMode.Set)
   End If

   ' print out the deskew angle
   Console.WriteLine("The rotation Amount is {0}", e.DeskewAngle)
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;

public void SliceCommandExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;

   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"));

   // Prepare the command
   SliceCommand cmd = new SliceCommand();
   cmd.FillColor = new RasterColor(0, 0, 0);
   cmd.MaximumDeskewAngle = 40;
   cmd.Flags = SliceCommandFlags.Bicubic | SliceCommandFlags.WithoutCut | SliceCommandFlags.DeskewImage;
   cmd.Slice += new EventHandler<SliceCommandEventArgs>(SliceEventExample_S1);

   // Apply the slice command on the image.
   cmd.Run(image);

   // Print out the deskew amount.
   Console.WriteLine("Deskew Angle = {0}", cmd.DeskewAngle);

}

private void SliceEventExample_S1(object sender, SliceCommandEventArgs e)
{
   // create a region around the slice
   if (e.Image.HasRegion)
      e.Image.AddRectangleToRegion(null, e.SliceRectangle, Leadtools.RasterRegionCombineMode.Xor);
   else
      e.Image.AddRectangleToRegion(null, e.SliceRectangle, Leadtools.RasterRegionCombineMode.Set);

   // print out the deskew angle
   Console.WriteLine("The rotation Amount is {0}", e.DeskewAngle);
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
function SliceCommandExample() {
   var codecs = new Leadtools.Codecs.RasterCodecs();
   codecs.throwExceptionsOnInvalidImages = true;

   // Load the image
   var srcFileName = "Assets\\Image1.cmp";
   var processedImage;
   return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
      return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile));
   }).then(function (image) {
      // Prepare the command
      with (Leadtools.ImageProcessing.Core) {
         var cmd = new SliceCommand();
         cmd.fillColor = Leadtools.RasterColorHelper.create(0, 0, 0);
         cmd.maximumDeskewAngle = 40;
         cmd.flags = SliceCommandFlags.bicubic | SliceCommandFlags.withoutCut | SliceCommandFlags.deskewImage;
         cmd.addEventListener("slice", SliceEventExample_S1);

         // Apply the slice command on the image.
         cmd.run(image);

         // Print out the deskew amount.
         console.error("Deskew Angle = {0}", cmd.deskewAngle);
      }
   });
}

function SliceEventExample_S1(e) {
   // create a region around the slice
   if (e.image.hasRegion)
      e.image.addRectangleToRegion(null, e.sliceRectangle, Leadtools.RasterRegionCombineMode.xor);
   else
      e.image.addRectangleToRegion(null, e.sliceRectangle, Leadtools.RasterRegionCombineMode.set);

   // print out the deskew angle
   console.error("The rotation Amount is {0}", e.deskewAngle);
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;

      
public async Task SliceCommandExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;
   // Load the image
   string srcFileName = @"Assets\Image1.cmp";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // Prepare the command
   SliceCommand cmd = new SliceCommand();
   cmd.FillColor = RasterColorHelper.Create(0, 0, 0);
   cmd.MaximumDeskewAngle = 40;
   cmd.Flags = SliceCommandFlags.Bicubic | SliceCommandFlags.WithoutCut | SliceCommandFlags.DeskewImage;
   cmd.Slice += new EventHandler<SliceCommandEventArgs>(SliceEventExample_S1);

   // Apply the slice command on the image.
   cmd.Run(image);

   // Print out the deskew amount.
   Debug.WriteLine("Deskew Angle = {0}", cmd.DeskewAngle);

}

private void SliceEventExample_S1(object sender, SliceCommandEventArgs e)
{
   // create a region around the slice
   if (e.Image.HasRegion)
      e.Image.AddRectangleToRegion(null, e.SliceRectangle, Leadtools.RasterRegionCombineMode.Xor);
   else
      e.Image.AddRectangleToRegion(null, e.SliceRectangle, Leadtools.RasterRegionCombineMode.Set);

   // print out the deskew angle
   Debug.WriteLine("The rotation Amount is {0}", e.DeskewAngle);
}
Requirements

Target Platforms

See Also

Reference

SliceCommand Members
Leadtools.ImageProcessing.Core Namespace

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.