Back to Aurora Vision Library website

You are here: Start » Function Reference » Computer Vision » Image Analysis » MeasureObjectWidth

MeasureObjectWidth


Header: AVL.h
Namespace: avl
Module: MetrologyBasic

Measures the width of an object using stripe detection.

Applications: Easy and precise measurement of distances between to straight parallel edges.

Syntax

C++
C#
 
void avl::MeasureObjectWidth
(
	const avl::Image& inImage,
	const atl::Array<avl::ScanMap>& inMeasurementMap,
	const avl::StripeScanParams& inStripeScanParams,
	avl::MeasureObjectMethod::Type inMeasureMethod,
	avl::Selection::Type inStripeSelection,
	atl::Optional<const avl::LocalBlindness&> inLocalBlindness,
	atl::Optional<avl::MEstimator::Type> inOutlierSuppression,
	int inOutlierCount,
	atl::Conditional<float>& outObjectWidth,
	atl::Conditional<avl::Segment2D>& outSegment1,
	atl::Conditional<avl::Segment2D>& outSegment2,
	atl::Optional<atl::Array<atl::Conditional<avl::Stripe1D>>&> outStripes = atl::NIL,
	atl::Optional<atl::Array<avl::Profile>&> outBrightnessProfiles = atl::NIL,
	atl::Optional<atl::Array<avl::Profile>&> outResponseProfiles = atl::NIL
)

Parameters

Name Type Default Description
Input value inImage const Image& Input image
Input value inMeasurementMap const Array<ScanMap>& Input measurement map
Input value inStripeScanParams const StripeScanParams& Parameters controlling the object stripe extraction process
Input value inMeasureMethod MeasureObjectMethod::Type Method used to measure the object
Input value inStripeSelection Selection::Type Selection::​Best Selection mode of edges of the object
Input value inLocalBlindness Optional<const LocalBlindness&> NIL Defines conditions in which weaker edges can be detected in the vicinity of stronger edges
Input value inOutlierSuppression Optional<MEstimator::Type> NIL Selects a method for ignoring incorrectly detected points
Input value inOutlierCount int Determines how many outlying points are rejected before the width is measured
Output value outObjectWidth Conditional<float>& Width of the object
Output value outSegment1 Conditional<Segment2D>& First edge of the object
Output value outSegment2 Conditional<Segment2D>& Second edge of the object
Output value outStripes Optional<Array<Conditional<Stripe1D>>&> NIL Detected stripes
Output value outBrightnessProfiles Optional<Array<Profile>&> NIL Extracted image profiles
Output value outResponseProfiles Optional<Array<Profile>&> NIL Profiles of the edge (derivative) operator response

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outStripes, outBrightnessProfiles, outResponseProfiles.

Read more about Optional Outputs.

Description

The filter measures the width of an object present in an image. Internally, it performs a series of scans with ScanSingleStripe filter using inMeasurementMap and inStripeScanParams. The so obtained points are then used for computing two parallel segments by means of a slightly modified segment fitting routine. The process is supported by inOutlierSuppression parameter. Finally, having the aforementioned stripe widths and fitted segments' direction, the object width can be computed using a selected inMeasureMethod method. The inOutlierCount stripe widths most differing from the median width are not used in this step. The inMeasurementMap should be created with CreateMeasurementMap function. For the filter to work properly, the scan segments do not have to be necessarily perpendicular to the object edges.

Hints

  • Define inStripeScanParams.StripePolarity to detect a particular edge type, and only that type.
  • If some points are not found, try decreasing inStripeScanParams.MinMagnitude.
  • If the object is more narrow than 6 pixels, change inStripeScanParams.ProfileInterpolation to Quadratic3.
  • Experiment with inOutlierSuppression and inOutlierCount to deal with some amount of incorrectly detected points.
  • Experiment with various values for inMeasureMethod to obtain best possible precision.

Examples

MeasureObjectWidth performed on the sample image. Green segments are diagScanSegments, the other two are the found object edges.

Errors

List of possible exceptions:

Error type Description
DomainError Invalid MeasurementMap in MeasureObjectWidth function. Use CreateMeasurementMap function to create it properly.

See Also

  • FitSegmentToEdges – Performs a series of 1D edge detections and finds a segment that best matches the detected points.