Back to Adaptive Vision Studio website

You are here: Start » Filter Reference » Image Analysis » CheckPresence_PixelAmount


Verifies object presence by analysing the amount of pixels that meet the specified criteria.

Name Type Range Description
inImage Image Input image
inRoi ShapeRegion Location at which object presence is being checked
inRoiAlignment CoordinateSystem2D* Adjusts the region of interest to the position of the inspected object
inColorModel HSxColorModel Selected color model
inBeginHue Integer 0 - 255 Begin of the range of acceptable hue
inEndHue Integer 0 - 255 End of the range of acceptable hue
inMinSaturation Integer 0 - 255 Lowest acceptable saturation
inMaxSaturation Integer* 0 - 255 Highest acceptable saturation
inMinBrightness Real* 0.0 - Lowest acceptable brightness
inMaxBrightness Real* 0.0 - Highest acceptable brightness
inMinAmount Real 0.0 - 1.0 Lowest acceptable fraction of pixels meeting the criteria
inMaxAmount Real 0.0 - 1.0 Highest acceptable fraction of pixels meeting the criteria
outIsPresent Bool Flag indicating whether the object is present or not
outAmount Real Fraction of pixels meeting the criteria
outForeground Region Region of pixels meeting the criteria
outAlignedRoi ShapeRegion Input ROI after transformation (in the image coordinates)
diagHsxImage Image Image represented in chosen color model


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

Read more about pixel formats in Image documentation.


Quick and easy presence verification, e.g. for missing caps, screws, labels.


The filter extracts foreground pixels by means of image thresholding and checks if their number comparing to the area of the whole ROI fits the range (inMinAmount, inMaxAmount). If the input image has 3 channels, the ThresholdToRegion_HSx filter is used for thresholding, and if the image has 1 channel (i.e. it is monochromatic), the simple ThresholdToRegion filter is performed. In the latter case only inMinBrightness and inMaxBrightness parameters matter.


  • Connect the inImage input with an appropriate image source. Make sure that this image is available (the program was previously run).
  • If the object location is variable, Connect an appropriate local coordinate system to inRoiAlignment.
  • Define inRoi to specify the image location at which the object presence will be checked.
  • Set inBeginHue and inEndHue to values appropriate for correct objects.
  • Limit the ranges of inMinSaturationinMaxSaturation and inMinBrightnessinMaxBrightness.
  • Verify that the outForeground output represents pixels belonging to correct objects.
  • Investigate the values that appear on the outAmount output, then set inMinAmount and inMaxAmount to values appropriate for correct objects.
  • When creating data previews, use outAlignedRoi and NOT inRoi as only the former will be properly aligned to the object location.


Description of usage of this filter can be found in examples and tutorial: Blister Inspection (NET GmbH), Finding Razor Head Defects.

CheckPresence_PixelAmount performed on sample image with inMinAmount = 0.7. The defects are present in red circles.


This filter can throw an exception to report error. Read how to deal with errors in Error Handling.

List of possible exceptions:

Error type Description
DomainError Incorrect inMaxBrightness value in CheckPresence_PixelAmount.
DomainError Incorrect inMinBrightness value in CheckPresence_PixelAmount.
DomainError Not supported inImage pixel format in CheckPresence_PixelAmount.

Complexity Level

This filter is available on Basic Complexity Level.

Filter Group

This filter is member of CheckPresence filter group.

See Also

  • ThresholdToRegion_HSx – Creates a region containing image pixels which belongs to specified region in HSV, HSL or HSI space.
  • ThresholdToRegion – Creates a region containing image pixels with values within the specified range.