C# Class Accord.Imaging.Filters.MaskedFilter

Apply filter according to the specified mask.

The image processing routine applies the specified BaseFilter to a source image according to the specified mask - if a pixel/value in the specified mask image/array is set to 0, then the original pixel's value is kept; otherwise the pixel is filtered using the specified base filter.

Mask can be specified as .NET's managed Bitmap, as UnmanagedImage or as byte array. In the case if mask is specified as image, it must be 8 bpp grayscale image. In all case mask size must be the same as size of the image to process.

Pixel formats accepted by this filter are specified by the BaseFilter.

Sample usage:

// create the filter MaskedFilter maskedFilter = new MaskedFilter( new Sepia( ), maskImage ); // apply the filter maskedFilter.ApplyInPlace( image );

Initial image:

Mask image:

Result image:

Inheritance: BaseInPlacePartialFilter
Mostra file Open project: accord-net/framework

Public Methods

Method Description
MaskedFilter ( IFilter baseFiler, Bitmap maskImage ) : System

Initializes a new instance of the MaskedFilter class.

MaskedFilter ( IFilter baseFiler, UnmanagedImage unmanagedMaskImage ) : System

Initializes a new instance of the MaskedFilter class.

MaskedFilter ( IFilter baseFiler, byte mask ) : System

Initializes a new instance of the MaskedFilter class.

Protected Methods

Method Description
ProcessFilter ( UnmanagedImage image, Rectangle rect ) : void

Process the filter on the specified image.

Private Methods

Method Description
ProcessImage ( UnmanagedImage image, Rectangle rect, byte mask, int maskLineSize ) : void

Method Details

MaskedFilter() public method

Initializes a new instance of the MaskedFilter class.
public MaskedFilter ( IFilter baseFiler, Bitmap maskImage ) : System
baseFiler IFilter Base filter to apply to the specified source image.
maskImage System.Drawing.Bitmap Mask image to use.
return System

MaskedFilter() public method

Initializes a new instance of the MaskedFilter class.
public MaskedFilter ( IFilter baseFiler, UnmanagedImage unmanagedMaskImage ) : System
baseFiler IFilter Base filter to apply to the specified source image.
unmanagedMaskImage UnmanagedImage Unmanaged mask image to use.
return System

MaskedFilter() public method

Initializes a new instance of the MaskedFilter class.
public MaskedFilter ( IFilter baseFiler, byte mask ) : System
baseFiler IFilter Base filter to apply to the specified source image.
mask byte to use.
return System

ProcessFilter() protected method

Process the filter on the specified image.
None of the possible mask properties were set. Need to provide mask before applying the filter. Invalid size of provided mask. Its size must be the same as the size of the image to mask.
protected ProcessFilter ( UnmanagedImage image, Rectangle rect ) : void
image UnmanagedImage Source image data.
rect System.Drawing.Rectangle Image rectangle for processing by the filter.
return void