You are here: Start » AVL.NET » Function Reference » Computer Vision » Image Segmentation » AVL.SegmentImage_Color

AVL.SegmentImage_Color

Segments an image basing on distance to model colors.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void SegmentImage_Color
(
	AvlNet.Image inImage,
	NullableRef<AvlNet.Region> inRoi,
	IList<AvlNet.Pixel> inReferenceColors,
	float inMaxDifference,
	NullableRef<IList<float>> inDifferenceMultipliers,
	float inChromaAmount,
	bool inForceDisjointRegions,
	IList<AvlNet.Region> outRegions
)

Parameters

Name Type Range Default Description
inImageAvlNet.ImageInput image.
inRoiAvlNet.NullableRef<AvlNet.Region>Range of pixels to be processed. Default value: atl::NIL.
inReferenceColorsSystem.Collections.Generic.IList<AvlNet.Pixel>Colors to compare pixels to.
inMaxDifferencefloat<0.0f, INF>5.0fMaximal difference between pixel and reference color to be accepted. Default value: 5.0f.
inDifferenceMultipliersAvlNet.NullableRef<System.Collections.Generic.IList<float>>Scales for maximum differences for each color. Default value: atl::NIL.
inChromaAmountfloat<0.0f, 1.0f>0.7fProportion of chromatic information in distance computation. Default value: 0.7f.
inForceDisjointRegionsboolForce output regions to be disjoint.
outRegionsSystem.Collections.Generic.IList<AvlNet.Region>Regions of pixels closest to colors.

Description

The operation finds regions of similar colors in RGB color space within inImage.

First, for each pixel of the input image its distance to each color in inReferenceColors is computed (see ColorDistanceImage function).

Then, for each reference color c, the function computes region of pixels that are closer to c than its corresponding threshold. In case inDifferenceMultipliers is Nil, threshold is equal to inMaxDifference. If inDifferenceMultipliers is not Nil, corresponding threshold is the product of inMaxDifference and the element of inDifferenceMultipliers that corresponds to c.

If flag inForceDisjointRegions is set to True, the regions are forced to be disjoint. In case a pixel has distance less than threshold for more than one color, distances are divided by thresholds and the minimum of ratios is taken. In particular, if the function works in one-threshold mode, the operation described above becomes simply minimum of distances.

Examples

SegmentImage_Color run with colors taken from three points with inChromaAmount = 0.7 and inMaxDifference = 15

Hardware Acceleration

This operation supports automatic parallelization for multicore and multiprocessor systems.

Hardware acceleration settings may be manipulated with Settings class.

Errors

List of possible exceptions:

Error type Description
DomainError Inconsistent array sizes in SegmentImage_Color.
DomainError Reference color array size too big in SegmentImage_Color.

Function Overrides

See also