AverageCommand Class (original) (raw)

Summary

Changes the color of each pixel in an image to the average color of pixels in its neighborhood. This results in a blur effect.

Syntax

C#

Objective-C

C++/CLI

Java

Python

@interface LTAverageCommand : LTRasterCommand 

public class AverageCommand extends RasterCommand

class AverageCommand(RasterCommand): 

Example

Run the AverageCommand on an image with a neighborhood Dimensions = 3x3 pixels.

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing.Effects; public void AverageCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "sample2.cmp")); // Prepare the command AverageCommand command = new AverageCommand(); // Average with a neighborhood of 3x3 pixels command.Dimension = 3; 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:\LEADTOOLS22\Resources\Images"; }