Back to Adaptive Vision Library website
You are here: Start » Function Reference » Image Analysis » CheckPresence_PixelAmount
CheckPresence_PixelAmount
Verifies object presence by analysing the amount of pixels that meet the specified criteria.
Syntax
C++
C#
void avl::CheckPresence_PixelAmount ( const avl::Image& inImage, const avl::ShapeRegion& inRoi, atl::Optional<const avl::CoordinateSystem2D&> inRoiAlignment, avl::HSxColorModel::Type inColorModel, int inBeginHue, int inEndHue, int inMinSaturation, atl::Optional<int> inMaxSaturation, atl::Optional<int> inMinBrightness, atl::Optional<int> inMaxBrightness, float inMinAmount, float inMaxAmount, bool& outIsPresent, atl::Optional<float&> outAmount = atl::NIL, atl::Optional<avl::Region&> outForeground = atl::NIL, atl::Optional<avl::ShapeRegion&> outAlignedRoi = atl::NIL, avl::Image& diagHsxImage )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
inImage | const Image& | Input image | |||
inRoi | const ShapeRegion& | Location at which object presence is being checked | |||
inRoiAlignment | Optional<const CoordinateSystem2D&> | NIL | Adjusts the region of interest to the position of the inspected object | ||
inColorModel | HSxColorModel::Type | Selected color model | |||
inBeginHue | int | 0 - 255 | 0 | Begin of the range of acceptable hue | |
inEndHue | int | 0 - 255 | 255 | End of the range of acceptable hue | |
inMinSaturation | int | 0 - 255 | 128 | Lowest acceptable saturation | |
inMaxSaturation | Optional<int> | 0 - 255 | NIL | Highest acceptable saturation | |
inMinBrightness | Optional<int> | 0 - 255 | 128 | Lowest acceptable brightness | |
inMaxBrightness | Optional<int> | 0 - 255 | NIL | Highest acceptable brightness | |
inMinAmount | float | 0.0 - 1.0 | 0.5f | Lowest acceptable fraction of pixels meeting the criteria | |
inMaxAmount | float | 0.0 - 1.0 | 1.0f | Highest acceptable fraction of pixels meeting the criteria | |
outIsPresent | bool& | Flag indicating whether the object is present or not | |||
outAmount | Optional<float&> | NIL | Fraction of pixels meeting the criteria | ||
outForeground | Optional<Region&> | NIL | Region of pixels meeting the criteria | ||
outAlignedRoi | Optional<ShapeRegion&> | NIL | Input ROI after transformation (in the image coordinates) | ||
diagHsxImage | Image& | Image represented in chosen color model |
Description
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.
Hints
- If the object location is variable, Pass 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 inMinSaturation–inMaxSaturation and inMinBrightness–inMaxBrightness.
- 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.