←Select platform

MaskConvolutionCommand Class

Summary
Applies various 3D effects to an image.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class MaskConvolutionCommand : RasterCommand 
@interface LTMaskConvolutionCommand : LTRasterCommand 
public class MaskConvolutionCommand 
    extends RasterCommand 
public ref class MaskConvolutionCommand : public RasterCommand   
class MaskConvolutionCommand(RasterCommand): 
Remarks
  • For EdgeDetection, the results are the same for opposite angles. For example, angles 0 and 180 have the same result when used with the edge detection mask.
  • When an image undergoes image convolution each pixel of the image is multiplied by a mask to create a new pixel value. The mask is an array of values that describes the weight that should be given to each of the pixels surrounding a specific pixel. The new pixel value is the result of the mask sum being divided by the mask weight. Using different masks result in different alterations of the image. The masks used in this command result in different types of edge detection.
  • As an example of the different masks, consider the following example:

    maskconvolution.jpg
  • To obtain these images, the following settings were used:

    Parameters Emboss Edge ESplotch Splotch
    Angle 0 0 180 0
    Depth 3 3 3 3
    Height 250 250 100 100
  • This command supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

  • This command does not support 32-bit grayscale images.

Mask Convolution Function - Before

Mask Convolution Function - Before

Mask Convolution Function - After

Mask Convolution Function - After

View additional platform support for this Mask Convolution function.

Example

Run the MaskConvolutionCommand on an image.

C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Effects; 
 
 
public void MaskConvolutionCommandExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\\NaturalFruits.jpg")); 
 
   // Prepare the command 
   MaskConvolutionCommand command = new MaskConvolutionCommand(); 
 
   // Apply 3D emboss effect on the image, with 0 degrees as the angle of apparent light, 
   // depth of 1.50, and height of 3 
   command.Angle = 0; 
   command.Depth = 150; 
   command.Height = 3; 
   command.Type = MaskConvolutionCommandType.Emboss; 
   command.Run(image); 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.assertTrue; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.effects.*; 
 
 
public void maskConvolutionCommandExample() { 
 
   Platform.loadLibrary(LTLibrary.DOCUMENT_WRITER); 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.setThrowExceptionsOnInvalidImages(true); 
 
   RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "NaturalFruits.jpg")); 
 
   // Prepare the command 
   MaskConvolutionCommand command = new MaskConvolutionCommand(); 
 
   // Apply 3D emboss effect on the image, with 0 degrees as the angle of apparent 
   // light, 
   // depth of 1.50, and height of 3 
   command.setAngle(0); 
   command.setDepth(150); 
   command.setHeight(3); 
   command.setType(MaskConvolutionCommandType.EMBOSS); 
   int change = command.run(image); 
   assertTrue(change != RasterImageChangedFlags.NONE); 
 
   codecs.save(image, combine(LEAD_VARS_IMAGES_DIR, "naturalFruitsResult.jpg"), RasterImageFormat.JPEG, 24); 
   System.out.println("Command run, image saved to " + (combine(LEAD_VARS_IMAGES_DIR, "naturalFruitsResult.jpg"))); 
} 
Requirements

Target Platforms

See Also

Reference

MaskConvolutionCommand Members

Leadtools.ImageProcessing.Effects Namespace

Leadtools.ImageProcessing.SpecialEffects.PlasmaCommand

EmbossCommand Class

SharpenCommand Class

Leadtools.ImageProcessing.Color.PosterizeCommand

MosaicCommand Class

AverageCommand Class

Leadtools.ImageProcessing.Core.MedianCommand

AddNoiseCommand Class

Leadtools.ImageProcessing.Color.IntensityDetectCommand

SpatialFilterCommand Class

BinaryFilterCommand Class

Leadtools.ImageProcessing.Core.MinimumCommand

Leadtools.ImageProcessing.Core.MaximumCommand

OilifyCommand Class

Leadtools.ImageProcessing.Color.SolarizeCommand

Leadtools.ImageProcessing.Core.WindowLevelCommand

Leadtools.ImageProcessing.SpecialEffects.BumpMapCommand

CubismCommand Class

Leadtools.ImageProcessing.SpecialEffects.DrawStarCommand

Leadtools.ImageProcessing.SpecialEffects.DryCommand

Leadtools.ImageProcessing.SpecialEffects.FreePlaneBendCommand

Leadtools.ImageProcessing.SpecialEffects.FreeRadialBendCommand

Leadtools.ImageProcessing.SpecialEffects.GlassEffectCommand

Leadtools.ImageProcessing.SpecialEffects.GlowCommand

Leadtools.ImageProcessing.SpecialEffects.LensFlareCommand

Leadtools.ImageProcessing.SpecialEffects.LightCommand

Leadtools.ImageProcessing.SpecialEffects.OceanCommand

Leadtools.ImageProcessing.SpecialEffects.PlaneBendCommand

Leadtools.ImageProcessing.SpecialEffects.PlaneCommand

Leadtools.ImageProcessing.Color.SampleTargetCommand

Leadtools.ImageProcessing.SpecialEffects.TunnelCommand

Leadtools.ImageProcessing.SpecialEffects.BendCommand

Leadtools.ImageProcessing.SpecialEffects.CylinderCommand

Leadtools.ImageProcessing.SpecialEffects.FreeHandShearCommand

Leadtools.ImageProcessing.SpecialEffects.FreeHandWaveCommand

Leadtools.ImageProcessing.SpecialEffects.ImpressionistCommand

Leadtools.ImageProcessing.SpecialEffects.PixelateCommand

Leadtools.ImageProcessing.SpecialEffects.PolarCommand

Leadtools.ImageProcessing.SpecialEffects.RadialBlurCommand

Leadtools.ImageProcessing.SpecialEffects.RadialWaveCommand

Leadtools.ImageProcessing.SpecialEffects.RippleCommand

Leadtools.ImageProcessing.SpecialEffects.SphereCommand

Leadtools.ImageProcessing.SpecialEffects.SwirlCommand

Leadtools.ImageProcessing.SpecialEffects.WaveCommand

Leadtools.ImageProcessing.SpecialEffects.WindCommand

Leadtools.ImageProcessing.SpecialEffects.ZoomBlurCommand

Leadtools.ImageProcessing.SpecialEffects.ZoomWaveCommand

Leadtools.ImageProcessing.SpecialEffects.ShadowCommand

Leadtools.ImageProcessing.SpecialEffects.RevEffectCommand

Leadtools.ImageProcessing.SpecialEffects.AgingCommand

Leadtools.ImageProcessing.SpecialEffects.DiceEffectCommand

Leadtools.ImageProcessing.SpecialEffects.FunctionalLightCommand

Leadtools.ImageProcessing.SpecialEffects.PuzzleEffectCommand

Leadtools.ImageProcessing.SpecialEffects.RingEffectCommand

TextureAlphaBlendCommand Class

Help Version 23.0.2024.3.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Effects Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.