Click or drag to resize
Accord.NET (logo)

ErrorDiffusionToAdjacentNeighbors Class

Base class for error diffusion dithering, where error is diffused to adjacent neighbor pixels.
Inheritance Hierarchy

Namespace:  Accord.Imaging.Filters
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.7.0
Syntax
public class ErrorDiffusionToAdjacentNeighbors : ErrorDiffusionDithering
Request Example View Source

The ErrorDiffusionToAdjacentNeighbors type exposes the following members.

Constructors
  NameDescription
Public methodErrorDiffusionToAdjacentNeighbors
Initializes a new instance of the ErrorDiffusionToAdjacentNeighbors class.
Top
Properties
  NameDescription
Public propertyCoefficients
Diffusion coefficients.
Public propertyFormatTranslations
Format translations dictionary.
(Inherited from ErrorDiffusionDithering.)
Public propertyThresholdValue
Threshold value.
(Inherited from ErrorDiffusionDithering.)
Top
Methods
  NameDescription
Public methodApply(Bitmap)
Apply filter to an image.
(Inherited from BaseInPlacePartialFilter.)
Public methodApply(BitmapData)
Apply filter to an image.
(Inherited from BaseInPlacePartialFilter.)
Public methodApply(UnmanagedImage)
Apply filter to an image in unmanaged memory.
(Inherited from BaseInPlacePartialFilter.)
Public methodApply(UnmanagedImage, UnmanagedImage)
Apply filter to an image in unmanaged memory.
(Inherited from BaseInPlacePartialFilter.)
Public methodApplyInPlace(Bitmap)
Apply filter to an image.
(Inherited from BaseInPlacePartialFilter.)
Public methodApplyInPlace(BitmapData)
Apply filter to an image.
(Inherited from BaseInPlacePartialFilter.)
Public methodApplyInPlace(UnmanagedImage)
Apply filter to an unmanaged image.
(Inherited from BaseInPlacePartialFilter.)
Public methodApplyInPlace(Bitmap, Rectangle)
Apply filter to an image or its part.
(Inherited from BaseInPlacePartialFilter.)
Public methodApplyInPlace(BitmapData, Rectangle)
Apply filter to an image or its part.
(Inherited from BaseInPlacePartialFilter.)
Public methodApplyInPlace(UnmanagedImage, Rectangle)
Apply filter to an unmanaged image or its part.
(Inherited from BaseInPlacePartialFilter.)
Protected methodDiffuse
Do error diffusion.
(Overrides ErrorDiffusionDitheringDiffuse(Int32, Byte*).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodProcessFilter
Process the filter on the specified image.
(Inherited from ErrorDiffusionDithering.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Protected fieldstartX
Processing X start position.
(Inherited from ErrorDiffusionDithering.)
Protected fieldstartY
Processing Y start position.
(Inherited from ErrorDiffusionDithering.)
Protected fieldstopX
Processing X stop position.
(Inherited from ErrorDiffusionDithering.)
Protected fieldstopY
Processing Y stop position.
(Inherited from ErrorDiffusionDithering.)
Protected fieldstride
Processing image's stride (line size).
(Inherited from ErrorDiffusionDithering.)
Protected fieldx
Current processing X coordinate.
(Inherited from ErrorDiffusionDithering.)
Protected fieldy
Current processing Y coordinate.
(Inherited from ErrorDiffusionDithering.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodToT
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The class does error diffusion to adjacent neighbor pixels using specified set of coefficients. These coefficients are represented by 2 dimensional jugged array, where first array of coefficients is for right-standing pixels, but the rest of arrays are for bottom-standing pixels. All arrays except the first one should have odd number of coefficients.

Suppose that error diffusion coefficients are represented by the next jugged array:

int[][] coefficients = new int[2][] {
    new int[1] { 7 },
    new int[3] { 3, 5, 1 }
};

The above coefficients are used to diffuse error over the next neighbor pixels (* marks current pixel, coefficients are placed to corresponding neighbor pixels):

    | * | 7 |
| 3 | 5 | 1 |

/ 16

The filter accepts 8 bpp grayscale images for processing.

Sample usage:

// create filter
ErrorDiffusionToAdjacentNeighbors filter = new ErrorDiffusionToAdjacentNeighbors(
    new int[3][] {
        new int[2] { 5, 3 },
        new int[5] { 2, 4, 5, 4, 2 },
        new int[3] { 2, 3, 2 }
    } );
// apply the filter
filter.ApplyInPlace( image );
See Also