MedianCommand Class (original) (raw)
Summary
Changes the color of each pixel in an image to the median color of pixels in its neighborhood. This is similar to the AverageCommand, but it is used for noise reduction, rather than a blur effect.
Syntax
C#
Objective-C
C++/CLI
Java
Python
@interface LTMedianCommand : LTRasterCommand
public class MedianCommand
extends RasterCommand
class MedianCommand(RasterCommand):
Example
Run the MedianCommand on an image and applies an median filter.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
public void MedianCommandExample()
{
// 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
MedianCommand command = new MedianCommand();
//Apply a median filter with a neighborhood of 9x9 pixels.
command.Dimension = 9;
command.Run(image);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools.ImageProcessing.Core Assembly