Back to Aurora Vision Library website

You are here: Start » Function Reference » Computer Vision » Image Segmentation » SegmentImage_Gray_Linear


Header: AVL.h
Namespace: avl
Module: FoundationPro

Segments an image into blobs examining differences between pixels values.

Applications: Detection of objects of undefined shape, but characterized by uniform brightness and good contrast to the background.


void avl::SegmentImage_Gray_Linear
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	avl::BlobMergingMethod::Type inMergingMethod,
	avl::RegionConnectivity::Type inConnectivity,
	int inMaxDifference,
	int inHysteresis,
	int inPassCount,
	bool inDirectional,
	int inMinArea,
	atl::Optional<int> inMaxArea,
	atl::Array<avl::Region>& outBlobs


Name Type Range Default Description
Input value
inImage const Image& Input image
Input value
inRoi Optional<const Region&> NIL Range of pixels to be processed
Input value
inMergingMethod BlobMergingMethod::Type Neighbor Defines a criterion by which two pixels can be merged into one blob
Input value
inConnectivity RegionConnectivity::Type Defines if pixels can be merged only horizontally and vertically, or also diagonally
Input value
inMaxDifference int 0 - 5 Maximal tonal difference that allows two pixels to be merged into one blob
Input value
inHysteresis int Total change of MaxDifference during all image passes
Input value
inPassCount int 1 - 5 Number of iterations in which the entire image is scanned for pixels that can be merged
Input value
inDirectional bool When 'True' the filter can segment results of GradientDirAndPresenceImage
Input value
inMinArea int 0 - 20 Minimal area of a blob that may be accepted
Input value
inMaxArea Optional<int> NIL Minimal area of a blob that may be accepted
Output value
outBlobs Array<Region>&


For input inImage only pixel formats are supported: 1⨯uint8, 1⨯int8, 1⨯uint16, 1⨯int16, 1⨯int32, 1⨯real, 3⨯uint8, 3⨯int8, 3⨯uint16, 3⨯int16, 3⨯int32, 3⨯real.

Read more about pixel formats in Image documentation.


The filter segments the inImage image into blobs of pixels which gray values do not differ too much. The classification is different depending on the inMergingMethod input:

  • Neighbor – two adjacent pixels are considered to belong to the same blob when their values differ by at most inMaxDifference
  • NeighborVerified – as above, but an additional verification is performed to avoid undersegmentation
  • Mean – pixel is considered to belong to an adjacent blob when its value differs by at most inMaxDifference from the mean value of this blob's pixels
  • MeanSorted – not implemented in this filter


SegmentImage_Gray_Linear performed on the sample image with inMaxDifference = 55, inMergingMethod = MeanLinear and inMinArea = 50.


List of possible exceptions:

Error type Description
DomainError Directional method only supports single-channel images.
DomainError Directional method only supports UInt8 images.
DomainError Two- and four-channel images are not supported in SegmentImage_Gray.
DomainError Not supported inImage pixel format in SegmentImage_Gray_Linear. Supported formats: 1xUInt8, 1xInt8, 1xUInt16, 1xInt16, 1xInt32, 1xReal, 3xUInt8, 3xInt8, 3xUInt16, 3xInt16, 3xInt32, 3xReal.

See Also

  • SegmentImage_Gray_Tiled – Segments an image into blobs examining differences between pixels values, first pass is tiled.