Click or drag to resize

ColorExtractionCommand Class

This command detects color regions from a color document resulting in an image with grayscale and bi-tonal areas masked with transparent alpha, and notification if the document contains any color.
Inheritance Hierarchy

Namespace:  Atalasoft.Imaging.ImageProcessing.Document
Assembly:  Atalasoft.dotImage.AdvancedDocClean (in Atalasoft.dotImage.AdvancedDocClean.dll) Version: (.NET 4.5.2, x86)
public class ColorExtractionCommand : ImageRegionCommand, 

The ColorExtractionCommand type exposes the following members.

Public methodColorExtractionCommand
Initializes a new instance of the ColorExtractionCommand class
Protected methodColorExtractionCommand(SerializationInfo, StreamingContext)
Initializes a new instance of the ColorExtractionCommand class
Public propertyApplyToAnyPixelFormat
Reports whether or not this command will be applied to any supplied PixelFormat image
(Inherited from ImageCommand.)
Public propertyCanApplyToAnyPixelFormat
Returns true if the command can be applied to any PixelFormat.
(Inherited from ImageCommand.)
Public propertyDetectColorMarkings
When true, color markings will be detected.
Public propertyDetectPhotos
When true, color and gray photos will be detected.
Public propertyGrayscaleSaturation
This value controls the saturation threshold where a saturation less than the given value will be regarded as gray.
Public propertyGrayscaleTolerance
This value controls the amount in percent that any given pixel color is off of pure gray.
Public propertyInPlaceProcessing
Gets a value indicating if the source image data is processed in-place as opposed to returning a new image.
(Inherited from ImageCommand.)
Public propertyMinMarkingSize
Minimum size limit of color markings in pixels.
Public propertyMinPhotoSize
Minimum size limit of photo regions in pixels.
Public propertyProgress
Gets or sets the ProgressEventHandler delegate which can be used to view or cancel the progress of the current process.
(Inherited from ImageCommand.)
Public propertyRegionOfInterest

Gets or sets a RegionOfInterest which will only process the indicated region of the image.

(Inherited from ImageRegionCommand.)
Public propertySpeedFactor
Determines the sample size of the image to process, affecting quality and speed.
Public propertySupportedPixelFormats
Gets a list of PixelFormats that this command will support without throwing an exception. This command supports color images only.
(Overrides ImageCommandSupportedPixelFormats.)
Public propertyVisualActivityThreshold
Controls the percentage of entropy threshold that factors in the photo detection algoithm.
Public propertyVisualActivityWindowSize
Specifies the masking window for estimating visual color activity used in photo region detection.
Public methodApply
Apply the command to the given image.
(Inherited from ImageCommand.)
Public methodApplyToImage Obsolete.
Applies the command to the source AtalaImage.
(Inherited from ImageCommand.)
Protected methodConstructChangedSourceImage
The method is called by the default implementation of Apply. It determines if it is necessary to create a copy of the source image in a different pixel format and if so, determines the best new pixel format and allocates that image.
(Inherited from ImageCommand.)
Protected methodConstructFinalImage (Overrides ImageCommandConstructFinalImage(AtalaImage).)
Protected methodConstructImageResults (Overrides ImageCommandConstructImageResults.)
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.)
Protected methodGetChangedPixelFormat
This method is called to change the pixel format of the source image.
(Inherited from ImageCommand.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetObjectData (Overrides ImageRegionCommandGetObjectData(SerializationInfo, StreamingContext).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodImageCommandGetObjectData
Aggregates ImageCommand data into the supplied SerializationInfo object.
(Inherited from ImageCommand.)
Public methodIsPixelFormatSupported
Returns a value indicating if the specified pixel format is supported.
(Inherited from ImageCommand.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodPerformActualCommand (Overrides ImageCommandPerformActualCommand(AtalaImage, AtalaImage, Rectangle, ImageResults).)
Protected methodSelectBestAlternatePixelFormat
Choose the best pixel format to use for this command when the supplied source image's pixel format is unacceptable.
(Inherited from ImageCommand.)
Protected methodSelectPreferredPixelFormat
Chooses a pixel format that is preferred for this command.
(Inherited from ImageCommand.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodVerifyImage
Verify the integrity of an AtalaImage.
(Inherited from ImageCommand.)
Protected methodVerifyProperties (Overrides ImageCommandVerifyProperties(AtalaImage).)

This command is very useful for scanning documents as color, and automatically detecting when a document has no color so that it can be converted to black and white for better compression. The Apply method will result in an instance of ColorExtractionResults that contains a ColorExtractionResults.HasColor property. When HasColor is false, the document has only gray shades and can be converted to black and white with little to no loss in quality. When HasColor is true, it generally means that the document has color regions and that it should remain a color document to retain this color information.

The resulting Image in ColorExtractionResults is always a 32-bit BGRA with a transparent alpha channel masking the non-color areas. When no color is detected the resulting Image is a 1x1 pixel transparent image.

There are two distinct types of color areas in a document. A color marking can be a highlight region, red pen, or other solid colors. A photo region is an area with a lot of visual activity usually represented in a color or grayscale photograph. This command has the ability to detect color markings, photos, or both.

The default values are optimized for detecting color in scanned documents. By adjusting GrayscaleTolerance to a higher level, this command can be used for other purposes such as detecting grayscale or color magazine scans.

See Also


ColorExtractionResults Class