You are here: Start » Function Reference » Image » Image Metrics » ColorDistanceImage
ColorDistanceImage
Header: | FIL.h |
---|---|
Namespace: | fil |
Module: | FoundationPro |
Compares each pixel with the specified color using chromatic and non-chromatic information.
Applications: Color analysis insensitive to changes of illumination.
Syntax
void fil::ColorDistanceImage ( const fil::Image& inImage, ftl::Optional<const fil::Region&> inRoi, const fil::Pixel& inRgbColor, float inChromaAmount, fil::Image& outValueImage )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
inImage | const Image& | Unsigned color image used in comparison | |||
inRoi | Optional<const Region&> | NIL | Range of pixels to be processed | ||
inRgbColor | const Pixel& | Color to compare the image to | |||
inChromaAmount | float | 0.0 - 1.0 | 0.7f | Proportion of chromatic information in distance computation | |
outValueImage | Image& | Unsigned image of distances |
Requirements
For input inImage only pixel formats are supported: 1⨯uint8, 2⨯uint8, 3⨯uint8, 4⨯uint8.
Read more about pixel formats in Image documentation.
Description
The operation computes the distance between each pixel of inImage and a specified color, presenting result as a monochromatic image. Input image should be in RGB color space.
The distance between pixels is computed using two measures:
- Value distance - the difference between average channel values
- Chromatic distance - euclidean distance between pixels normalized to the same value level
The resulting distance is computed as a weighted average of these two values, parameter inChromaAmount ( 0.0 - 1.0 ) being the weight of the chromatic distance, and 1 - inChromaAmount being the weight of the value distance.
Examples
Hardware Acceleration
This operation supports automatic parallelization for multicore and multiprocessor systems.
Errors
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Invalid image Depth in ColorDistanceImage. |
DomainError | Not supported inImage pixel format in ColorDistanceImage. Supported formats: 1xUInt8, 2xUInt8, 3xUInt8, 4xUInt8. |
RuntimeError | Each pixel component of inRgbColor must be nonnegative in ColorDistanceImage. |
See Also
- ColorDistance – Compares two pixels using chromatic and non-chromatic information. Assumes RGB color space.
- ThresholdToRegion_Color – Creates a region containing image pixels with values close to the given color.
- ThresholdImage_Color – Transforms each pixel value to maximum or minimum depending on the distance from a given color.