LEADTOOLS画像処理(Leadtools.ImageProcessing.Effectsアセンブリ)

フレームを表示

UserFilterCommandクラス








メンバ 
ユーザー定義のフィルタ/マスクに基づくimageをフィルタリングします。このコマンドは、空間やバイナリのフィルタコマンドと似ています。
オブジェクトモデル
構文
'Declaration
 
Public Class UserFilterCommand 
   Inherits Leadtools.ImageProcessing.RasterCommand
   Implements Leadtools.ImageProcessing.IRasterCommand 
'Usage
 
Dim instance As UserFilterCommand
public sealed class UserFilterCommand : Leadtools.ImageProcessing.IRasterCommand  
@interface LTUserFilterCommand : LTRasterCommand
public class UserFilterCommand extends RasterCommand
function Leadtools.ImageProcessing.Effects.UserFilterCommand()
解説
サンプル

imageの上でUserFilterCommandを実行します、このサンプルに、高いpass.filterはユーザー定義のマトリックスを用いて適用されます。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Effects

   
Public Sub UserFilterCommandExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True
   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))

   ' Prepare the command
   Dim i As Integer
   Dim j As Integer
   Dim matrix() As Integer
   ReDim matrix(8)

   Dim command As UserFilterCommand = New UserFilterCommand
   command.CenterPoint = New LeadPoint(1, 1)
   command.Divisor = 1
   command.Offset = 0
   command.Type = UserFilterCommandType.Sum
   command.FilterHeight = 3
   command.FilterWidth = 3
   command.Matrix = matrix

   ' Initialize the array with factor used to apply the high pass filter.
   For i = 0 To 2
      For j = 0 To 2
         If (j = 1 Or i = 1) Then
            If (j = 1 And i = 1) Then
               command.Matrix(i * 3 + j) = 5
            Else
               command.Matrix(i * 3 + j) = -1
            End If
         Else
            command.Matrix(i * 3 + j) = 0
         End If
      Next
   Next

   ' Apply the high pass custom filter.
   command.Run(leadImage)
   codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24)

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.Effects;

      
public void UserFilterCommandExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"));

   // Prepare the command
   int i, j;
   UserFilterCommand command = new UserFilterCommand();
   command.CenterPoint = new LeadPoint(1, 1);
   command.Divisor = 1;
   command.Offset = 0;
   command.Type = UserFilterCommandType.Sum;
   command.FilterHeight = 3;
   command.FilterWidth = 3;
   command.Matrix = new int[9];

   // Initialize the array with factor used to apply the high pass filter.
   for(i = 0; i < 3; i++)
   {
      for(j = 0; j < 3; j++)
      {
         if(j == 1 || i == 1) 
         {
            if(j == 1 && i == 1) 
               command.Matrix[i * 3 + j] = 5; 
            else 
               command.Matrix[i * 3 + j] = -1; 
         }
         else
            command.Matrix[i * 3 + j] = 0; 
      }
   }

   // Apply the high pass custom filter.
   command.Run(image);

}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Effects;
using Leadtools.ImageProcessing;

      
public async Task UserFilterCommandExample()
{
   // 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
   int i, j;
   UserFilterCommand command = new UserFilterCommand();
   command.CenterPoint = LeadPointHelper.Create(1, 1);
   command.Divisor = 1;
   command.Offset = 0;
   command.Type = UserFilterCommandType.Sum;
   command.FilterHeight = 3;
   command.FilterWidth = 3;
   command.Matrix = new int[9];

   // Initialize the array with factor used to apply the high pass filter.
   for(i = 0; i < 3; i++)
   {
      for(j = 0; j < 3; j++)
      {
         if(j == 1 || i == 1) 
         {
            if(j == 1 && i == 1) 
               command.Matrix[i * 3 + j] = 5; 
            else 
               command.Matrix[i * 3 + j] = -1; 
         }
         else
            command.Matrix[i * 3 + j] = 0; 
      }
   }

   // Apply the high pass custom filter.
   command.Run(image);

}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Effects;
using Leadtools.Examples;

public void UserFilterCommandExample(RasterImage image, Stream outStream)
{
   // Prepare the command
   int i, j;
   UserFilterCommand command = new UserFilterCommand();
   command.CenterPoint = new LeadPoint(1, 1);
   command.Divisor = 1;
   command.Offset = 0;
   command.Type = UserFilterCommandType.Sum;
   command.FilterHeight = 3;
   command.FilterWidth = 3;
   command.Matrix = new int[9];
   // Initialize the array with factor used to apply the high pass filter.
   for (i = 0; i < 3; i++)
   {
      for (j = 0; j < 3; j++)
      {
         if (j == 1 || i == 1)
         {
            if (j == 1 && i == 1)
               command.Matrix[i * 3 + j] = 5;
            else
               command.Matrix[i * 3 + j] = -1;
         }
         else
            command.Matrix[i * 3 + j] = 0;
      }
   }

   // Apply the high pass custom filter.
   command.Run(image);
   // Save result image
   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);
   image.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Effects

Public Sub UserFilterCommandExample(ByVal image As RasterImage, ByVal outStream As Stream)
   ' Prepare the command
   Dim i, j As Integer
   Dim command As UserFilterCommand = New UserFilterCommand()
   command.CenterPoint = New LeadPoint(1, 1)
   command.Divisor = 1
   command.Offset = 0
   command.Type = UserFilterCommandType.Sum
   command.FilterHeight = 3
   command.FilterWidth = 3
   command.Matrix = New Integer(8){}
   ' Initialize the array with factor used to apply the high pass filter.
   For i = 0 To 2
      For j = 0 To 2
         If j = 1 OrElse i = 1 Then
            If j = 1 AndAlso i = 1 Then
               command.Matrix(i * 3 + j) = 5
            Else
               command.Matrix(i * 3 + j) = -1
            End If
         Else
            command.Matrix(i * 3 + j) = 0
         End If
      Next j
   Next i

   ' Apply the high pass custom filter.
   command.Run(image)
   ' Save result image
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)
   image.Dispose()
End Sub
必要条件

ターゲットプラットホーム

参照

参照

UserFilterCommandメンバ
Leadtools.ImageProcessing.Effects名前空間
Leadtools.ImageProcessing.Core.MinimumCommand
Leadtools.ImageProcessing.Core.MaximumCommand
AddNoiseCommandクラス
SharpenCommandクラス
Leadtools.ImageProcessing.Color.PosterizeCommand
MosaicCommandクラス
EmbossCommandクラス
AverageCommandクラス
Leadtools.ImageProcessing.Core.MedianCommand
Leadtools.ImageProcessing.Color.IntensityDetectCommand
SpatialFilterCommandクラス
BinaryFilterCommandクラス
OilifyCommandクラス
Leadtools.ImageProcessing.Color.SolarizeCommand
Leadtools.ImageProcessing.Core.WindowLevelCommand
Leadtools.ImageProcessing.SpecialEffects.ShadowCommand
Leadtools.ImageProcessing.Color.ChangeHueSaturationIntensityCommand
Leadtools.ImageProcessing.Color.ColorReplaceCommand
Leadtools.ImageProcessing.Color.ColorThresholdCommand
Leadtools.ImageProcessing.Core.DiscreteFourierTransformCommand
DirectionEdgeStatisticalCommandクラス
Leadtools.ImageProcessing.Core.FastFourierTransformCommand
Leadtools.ImageProcessing.Core.FrequencyFilterCommand
Leadtools.ImageProcessing.Core.FrequencyFilterMaskCommand
Leadtools.ImageProcessing.Core.FourierTransformDisplayCommand
StatisticsInformationCommandクラス
FeretsDiameterCommandクラス
ObjectInformationCommandクラス
RegionContourPointsCommandクラス
GetRegionPerimeterLengthメソッド
Leadtools.ImageProcessing.Color.MathematicalFunctionCommand
Leadtools.ImageProcessing.SpecialEffects.RevEffectCommand
Leadtools.ImageProcessing.Color.SegmentCommand
Leadtools.ImageProcessing.Core.SubtractBackgroundCommand
HighPassCommandクラス