Skip to content

spatial_relationSpatialRelationSpatialRelationspatial_relationT_spatial_relation๐Ÿ”—

Short description๐Ÿ”—

spatial_relationSpatialRelationSpatialRelationspatial_relationT_spatial_relation โ€” Pose relation of regions with regard to ย the coordinate axes.

Signature๐Ÿ”—

spatial_relation( region Regions1, region Regions2, integer Percent, out integer RegionIndex1, out integer RegionIndex2, out string Relation1, out string Relation2 )void SpatialRelation( const HObject& Regions1, const HObject& Regions2, const HTuple& Percent, HTuple* RegionIndex1, HTuple* RegionIndex2, HTuple* Relation1, HTuple* Relation2 )static void HOperatorSet.SpatialRelation( HObject regions1, HObject regions2, HTuple percent, out HTuple regionIndex1, out HTuple regionIndex2, out HTuple relation1, out HTuple relation2 )def spatial_relation( regions_1: HObject, regions_2: HObject, percent: int ) -> Tuple[Sequence[int], Sequence[int], Sequence[str], Sequence[str]]

Herror T_spatial_relation( const Hobject Regions1, const Hobject Regions2, const Htuple Percent, Htuple* RegionIndex1, Htuple* RegionIndex2, Htuple* Relation1, Htuple* Relation2 )

HTuple HRegion::SpatialRelation( const HRegion& Regions2, Hlong Percent, HTuple* RegionIndex2, HTuple* Relation1, HTuple* Relation2 ) const

HTuple HRegion.SpatialRelation( HRegion regions2, int percent, out HTuple regionIndex2, out HTuple relation1, out HTuple relation2 )

Description๐Ÿ”—

The operator spatial_relationSpatialRelation selects regions located by Percentpercentpercent percent โ€œleftโ€, โ€œrightโ€, โ€œaboveโ€ or โ€œbelowโ€ other regions. Regions1regions1regions_1 and Regions2regions2regions_2 contain the regions to be compared. Regions1regions1regions_1 can have three states:

The percentage Percentpercentpercent is interpreted in such a way that the area of the second region has to be located really left/right or ย above/below the region margins of the first region by at least Percentpercentpercent percent. The indices of the regions that fulfill at least one of these conditions are then located at the n-th position in the output parameters RegionIndex1regionIndex1region_index_1 and RegionIndex2regionIndex2region_index_2. Additionally the output parameters Relation1relation1relation_1 and Relation2relation2relation_2 contain at the n-th position the type of relation of the region pair (RegionIndex1regionIndex1region_index_1[n], RegionIndex2regionIndex2region_index_2[n]), i.e., region with index RegionIndex2regionIndex2region_index_2[n] has the relation Relation1relation1relation_1[n] and Relation2relation2relation_2[n] with region with index RegionIndex1regionIndex1region_index_1[n].

Possible values for Relation1relation1relation_1 and Relation2relation2relation_2 are:

In RegionIndex1regionIndex1region_index_1 and RegionIndex2regionIndex2region_index_2 the indices of the regions in the tuples of the input regions (Regions1regions1regions_1 or
Regions2regions2regions_2), respectively, are entered as image identifiers. Access to chosen regions via the index can be obtained by the operator copy_objCopyObj.

Execution information๐Ÿ”—

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

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

  • Processed without parallelization.

Parameters๐Ÿ”—

Regions1regions1regions_1 (input_object) region(-array) โ†’ objectHObjectHRegionHObjectHobject

Starting regions.

Regions2regions2regions_2 (input_object) region(-array) โ†’ objectHObjectHRegionHObjectHobject

Comparative regions.

Percentpercentpercent (input_control) integer โ†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Percentage of the area of the comparative region which must be located left/right orย above/below the region margins of the starting region.

Default: 5050
Suggested values: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1000, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
Value range: 0 โ‰ค Percent โ‰ค 100 (lin)
Minimum increment: 1
Recommended increment: 10

RegionIndex1regionIndex1region_index_1 (output_control) integer-array โ†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Indices of the regions in the tuple of the input regions which fulfill the pose relation.

RegionIndex2regionIndex2region_index_2 (output_control) integer-array โ†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Indices of the regions in the tuple of the input regions which fulfill the pose relation.

Relation1relation1relation_1 (output_control) string-array โ†’ (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Vertical pose relation in which RegionIndex2regionIndex2region_index_2[n] stands with RegionIndex1regionIndex1region_index_1[n].

Relation2relation2relation_2 (output_control) string-array โ†’ (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Horizontal pose relation in which RegionIndex2regionIndex2region_index_2[n] stands with RegionIndex1regionIndex1region_index_1[n].

Result๐Ÿ”—

The operator spatial_relationSpatialRelation returns the value 2 (H_MSG_TRUE) if Regions2regions2regions_2 is not empty and Percentpercentpercent is correctly chosen. The behavior in case of empty parameter Regions2regions2regions_2 (no input regions available) is set via the operator set_system('no_object_result',<Result>). The behavior in case of empty region (the region is the empty set) is set via set_system('empty_region_result',<Result>). If necessary an exception is raised.

Combinations with other operators๐Ÿ”—

Combinations

Possible predecessors

thresholdThreshold, regiongrowingRegiongrowing, connectionConnection

Alternatives

area_centerAreaCenter, intersectionIntersection

See also

select_region_spatialSelectRegionSpatial, find_neighborsFindNeighbors, copy_objCopyObj, obj_to_integerObjToInteger

Module๐Ÿ”—

Foundation