Initializes a new UserFilterCommand class object with explicit parameters.
public UserFilterCommand(int filterWidth,int filterHeight,LeadPoint centerPoint,int divisor,int offset,UserFilterCommandType type,int[] matrix)
Public Function New( _ByVal filterWidth As Integer, _ByVal filterHeight As Integer, _ByVal centerPoint As LeadPoint, _ByVal divisor As Integer, _ByVal offset As Integer, _ByVal type As UserFilterCommandType, _ByVal matrix() As Integer _)
- (instancetype)initWithFilterWidth:(NSUInteger)filterWidthfilterHeight:(NSUInteger)filterHeightcenterPoint:(LeadPoint)centerPointdivisor:(NSUInteger)divisoroffset:(NSInteger)offsettype:(LTUserFilterCommandType)typematrix:(nullable const int *)matrixmatrixLength:(NSUInteger)matrixLength
public UserFilterCommand(int filterWidth,int filterHeight,LeadPoint centerPoint,int divisor,int offset,UserFilterCommandType type,int[] matrix)
public:UserFilterCommand(int filterWidth,int filterHeight,LeadPoint centerPoint,int divisor,int offset,UserFilterCommandType type,array<int>^ matrix)
filterWidth
Number of columns in the user-defined array (mask). This parameter only accepts positive values.
filterHeight
Number of rows in the user-defined array (mask). This parameter only accepts positive values.
centerPoint
Any two-dimensional position of the matrix array, to be used as the matrix (mask)center.
divisor
Value used to divide the final result of the output. This must be a non-zero value. If you want to use floating point values for the matrix elements and the divisor, multiply the matrix elements and the divisor with the same value (for example, 10, 100, 1000). This parameter only accepts positive values.
offset
Value used to offset the final result of the output.
type
Flag that indicates the type of operation.
matrix
Array of (filterWidth * filterHeight) integers containing the user-defined matrix (mask). The elements are stored in row order (first row, second row, etc).
Run the UserFilterCommand on an image, In this example the high pass.filter will be applied using user defined matrix.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing.Effects;public void UserFilterConstructorExample(){// Load an imageRasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"));// Prepare the commandint[] matrix = new int[9];// Initialize the array with factor used to apply the high pass filter.for (int i = 0; i < 3; i++){for (int j = 0; j < 3; j++){if (j == 1 || i == 1){if (j == 1 && i == 1)matrix[i * 3 + j] = 5;elsematrix[i * 3 + j] = -1;}elsematrix[i * 3 + j] = 0;}}UserFilterCommand command = new UserFilterCommand(3, 3, new LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix);// Apply the high pass custom filter.command.Run(image);}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.EffectsPublic Sub UserFilterConstructorExample()Dim codecs As New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = TrueDim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))' Prepare the commandDim i As IntegerDim j As IntegerDim matrix() As IntegerReDim matrix(8)' Initialize the array with factor used to apply the high pass filter.For i = 0 To 2For j = 0 To 2If (j = 1 Or i = 1) ThenIf (j = 1 And i = 1) Thenmatrix(i * 3 + j) = 5Elsematrix(i * 3 + j) = -1End IfElsematrix(i * 3 + j) = 0End IfNextNextDim command As UserFilterCommand = New UserFilterCommand(3, 3, New LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix)' Apply the high pass custom filter.command.Run(leadImage)codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24)End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
c#[Silverlight C# Example]using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing.Effects;using Leadtools.Examples;public void UserFilterConstructorExample(RasterImage image, Stream outStream){// Prepare the commandint[] matrix = new int[9];// Initialize the array with factor used to apply the high pass filter.for (int i = 0; i < 3; i++){for (int j = 0; j < 3; j++){if (j == 1 || i == 1){if (j == 1 && i == 1)matrix[i * 3 + j] = 5;elsematrix[i * 3 + j] = -1;}elsematrix[i * 3 + j] = 0;}}UserFilterCommand command = new UserFilterCommand(3, 3, new LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix);// Apply the high pass custom filter.command.Run(image);// Save result imageRasterCodecs codecs = new RasterCodecs();codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);image.Dispose();}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessing.EffectsPublic Sub UserFilterConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream)' Prepare the commandDim matrix As Integer() = New Integer(8) {}' Initialize the array with factor used to apply the high pass filter.For i As Integer = 0 To 2For j As Integer = 0 To 2If j = 1 OrElse i = 1 ThenIf j = 1 AndAlso i = 1 Thenmatrix(i * 3 + j) = 5Elsematrix(i * 3 + j) = -1End IfElsematrix(i * 3 + j) = 0End IfNext jNext iDim command As UserFilterCommand = New UserFilterCommand(3, 3, New LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix)' Apply the high pass custom filter.command.Run(image)' Save result imageDim codecs As RasterCodecs = New RasterCodecs()codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)image.Dispose()End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
