connectionconnectionConnectionConnectionconnection连接(算子)
名称
connectionconnectionConnectionConnectionconnection — 计算区域的连通分量。
签名
def connection(region: HObject) -> HObject
描述
connectionconnectionConnectionConnectionConnectionconnection 用于确定 RegionRegionRegionRegionregionregion 中给定输入区域的连通分量。其邻域可通过 set_system('neighborhood',<4/8>)set_system("neighborhood",<4/8>)SetSystem("neighborhood",<4/8>)SetSystem("neighborhood",<4/8>)SetSystem("neighborhood",<4/8>)set_system("neighborhood",<4/8>) 设置,默认值为 8-邻域,适用于确定前景的连通分量。connectionconnectionConnectionConnectionConnectionconnection 返回的连通分量最大数量可通过 set_system('max_connection',<Num>)set_system("max_connection",<Num>)SetSystem("max_connection",<Num>)SetSystem("max_connection",<Num>)SetSystem("max_connection",<Num>)set_system("max_connection",<Num>) 设置。默认值 0 表示返回所有连通分量。connectionconnectionConnectionConnectionConnectionconnection 的逆运算为 union1union1Union1Union1Union1union1。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 在内部数据级别上自动并行化。
参数
RegionRegionRegionRegionregionregion (输入对象) region(-array) → objectHRegionHObjectHRegionHobject
输入区域。
ConnectedRegionsConnectedRegionsConnectedRegionsConnectedRegionsconnectedRegionsconnected_regions (输出对象) region-array → objectHRegionHObjectHRegionHobject *
连通分量。
示例(HDevelop)
read_image(Image,'clip')
dev_set_colored(12)
threshold(Image,Dark,0,150)
count_obj(Dark,NumThresholded)
dev_display (Dark)
connection(Dark,ConnectedRegions)
count_obj(ConnectedRegions,NumConnected)
dev_display (ConnectedRegions)
示例(C)
read_image(&Image,"monkey");
set_colored(WindowHandle,12);
threshold(Image,&Light,150.0,255.0);
count_obj(Light,&Number1);
printf("Number of regions after threshold = %d\n",Number1);
disp_region(Light,WindowHandle);
connection(Light,&Many);
count_obj(Many,&Number2);
printf("Number of regions after threshold = %d\n",Number2);
disp_region(Many,WindowHandle);
示例(HDevelop)
read_image(Image,'clip')
dev_set_colored(12)
threshold(Image,Dark,0,150)
count_obj(Dark,NumThresholded)
dev_display (Dark)
connection(Dark,ConnectedRegions)
count_obj(ConnectedRegions,NumConnected)
dev_display (ConnectedRegions)
示例(HDevelop)
read_image(Image,'clip')
dev_set_colored(12)
threshold(Image,Dark,0,150)
count_obj(Dark,NumThresholded)
dev_display (Dark)
connection(Dark,ConnectedRegions)
count_obj(ConnectedRegions,NumConnected)
dev_display (ConnectedRegions)
示例(HDevelop)
read_image(Image,'clip')
dev_set_colored(12)
threshold(Image,Dark,0,150)
count_obj(Dark,NumThresholded)
dev_display (Dark)
connection(Dark,ConnectedRegions)
count_obj(ConnectedRegions,NumConnected)
dev_display (ConnectedRegions)
复杂度
设 F 为输入区域的面积,N 为生成的连通分量数。则运行时间复杂度为O(√F * √N)。
结果
connectionconnectionConnectionConnectionConnectionconnection 始终返回值 2 (H_MSG_TRUE)。当输入为空(未指定区域)时,可设置行为通过算子 set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>),以及输入区域为空时,可设置行为通过算子 set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>)。如有必要,则抛出异常。
可能的前趋
auto_thresholdauto_thresholdAutoThresholdAutoThresholdAutoThresholdauto_threshold,
thresholdthresholdThresholdThresholdThresholdthreshold,
dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold,
erosion1erosion1Erosion1Erosion1Erosion1erosion1
可能的后继
select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape,
select_grayselect_graySelectGraySelectGraySelectGrayselect_gray,
shape_transshape_transShapeTransShapeTransShapeTransshape_trans,
set_coloredset_coloredSetColoredSetColoredSetColoredset_colored,
dilation1dilation1Dilation1Dilation1Dilation1dilation1,
count_objcount_objCountObjCountObjCountObjcount_obj,
reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain,
add_channelsadd_channelsAddChannelsAddChannelsAddChannelsadd_channels
替代
background_segbackground_segBackgroundSegBackgroundSegBackgroundSegbackground_seg
另见
set_systemset_systemSetSystemSetSystemSetSystemset_system,
union1union1Union1Union1Union1union1
模块
基础