Skip to content

complementComplementComplementcomplementcomplement🔗

Short description🔗

complementComplementComplementcomplementcomplement — Return the complement of a region.

Signature🔗

complement( region Region, out region RegionComplement )void Complement( const HObject& Region, HObject* RegionComplement )static void HOperatorSet.Complement( HObject region, out HObject regionComplement )def complement( region: HObject ) -> HObject

Herror complement( const Hobject Region, Hobject* RegionComplement )

Herror T_complement( const Hobject Region, Hobject* RegionComplement )

HRegion HRegion::Complement( ) const

HRegion HRegion.Complement( )

Description🔗

complementComplement determines the complement of the input region(s).

If the system flag 'clip_region'"clip_region" is 'true'"true", which is the default, the difference of the largest image processed so far (see reset_obj_dbResetObjDb) and the input region is returned.

If the system flag 'clip_region'"clip_region" is 'false'"false" (see set_systemSetSystem), the resulting region would be infinitely large. To avoid this, the complement is done only virtually by setting the complement flag of Regionregionregion to TRUE. For succeeding operations the de Morgan laws are applied while calculating results. Using complementComplement with 'clip_region'"clip_region" set to 'false'"false" makes sense only to avoid fringe effects, e.g., if the area of interest is bigger or smaller than the image. For the latter case, the clipping would be set explicitly. If there is no reason to use the operator with 'clip_region'"clip_region"='false'"false" but you need the flag for other operations of your program, it is recommended to temporarily set the system flag to'true'"true" and change it back to 'false'"false" after applying complementComplement. Otherwise, negative regions may result from succeeding operations.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

Parameters🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

Input region(s).

RegionComplementregionComplementregion_complement (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Complemented regions.

Number of elements: RegionComplement == Region

Result🔗

complementComplement always returns the value 2 (H_MSG_TRUE). The behavior in case of empty input (no regions given) can be set via set_system('no_object_result',<Result>) and the behavior in case of an empty input region via set_system('empty_region_result',<Result>). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

thresholdThreshold, connectionConnection, regiongrowingRegiongrowing, pouringPouring, class_ndim_normClassNdimNorm

Possible successors

select_shapeSelectShape

See also

differenceDifference, union1Union1, union2Union2, intersectionIntersection, reset_obj_dbResetObjDb, set_systemSetSystem

Module🔗

Foundation