C# Class Accord.Imaging.Filters.Grayscale

Base class for image grayscaling.

This class is the base class for image grayscaling. Other classes should inherit from this class and specify RGB coefficients used for color image conversion to grayscale.

The filter accepts 24, 32, 48 and 64 bpp color images and produces 8 (if source is 24 or 32 bpp image) or 16 (if source is 48 or 64 bpp image) bpp grayscale image.

Sample usage:

// create grayscale filter (BT709) Grayscale filter = new Grayscale( 0.2125, 0.7154, 0.0721 ); // apply the filter Bitmap grayImage = filter.Apply( image );

Initial image:

Result image:

Inheritance: BaseFilter
Show file Open project: accord-net/framework Class Usage Examples

Public Properties

Property Type Description
BlueCoefficient double
GreenCoefficient double
RedCoefficient double

Public Methods

Method Description
Grayscale ( double cr, double cg, double cb ) : System

Initializes a new instance of the Grayscale class.

Protected Methods

Method Description
ProcessFilter ( UnmanagedImage sourceData, UnmanagedImage destinationData ) : void

Process the filter on the specified image.

Method Details

Grayscale() public method

Initializes a new instance of the Grayscale class.
public Grayscale ( double cr, double cg, double cb ) : System
cr double Red coefficient.
cg double Green coefficient.
cb double Blue coefficient.
return System

ProcessFilter() protected method

Process the filter on the specified image.
protected ProcessFilter ( UnmanagedImage sourceData, UnmanagedImage destinationData ) : void
sourceData UnmanagedImage Source image data.
destinationData UnmanagedImage Destination image data.
return void

Property Details

BlueCoefficient public property

Portion of blue channel's value to use during conversion from RGB to grayscale.
public double BlueCoefficient
return double

GreenCoefficient public property

Portion of green channel's value to use during conversion from RGB to grayscale.
public double GreenCoefficient
return double

RedCoefficient public property

Portion of red channel's value to use during conversion from RGB to grayscale.
public double RedCoefficient
return double