测试图像
1.如果检测区域只覆盖中间则"边缘幅度阈值"在20左右可以检出,结果如下图
检测区域覆盖中间区域
检测区域覆盖中间区域结果
2.如果检测区域覆盖较高则"边缘幅度阈值"只能设置到5左右可以检出,结果如下图
检测区域覆盖整个区域
检测区域覆盖整个区域结果
3.担心的是边缘幅度阈值设置到5是一个比较小的灰度,可能容易出现误检,哪位大佬指点一下
不理解的是这里设置比较高的检测区域时是否可以只检测中间比较明显的区域,得到类似上图的结果,可以不检出下侧较暗的边缘
- read_image (Image, '计量模型线条检测.png')
- get_image_size (Image, Width, Height)
- ********************************************************************************
- *创建二维测量模型
- create_metrology_model (MetrologyHandle)
- set_metrology_model_image_size (MetrologyHandle, Width, Height)
- ********************************************************************************
- *添加测量对象到测量模型
- *第一种测量区域, 从图像上侧到下侧, 此时需要设置很小的边缘幅度阈值才能拟合出来, 阈值大概在5左右.
- *add_metrology_object_line_measure (MetrologyHandle, 0, 0.5*Width, Height, 0.5*Width, 20, 5, 1, 30, [], [], Index)
- *第二种测量区域, 只针对图像中部明显区域, 边缘幅度阈值阈值在20左右可以拟合出来.
- add_metrology_object_line_measure (MetrologyHandle, 150, 0.5*Width, Height-150, 0.5*Width, 20, 5, 1, 30, [], [], Index)
- get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row, Column)
- ********************************************************************************
- ****Creating measure regions:
- *'measure_length1': 区域, 垂直于边界的测量区域的一半长度
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_length1', 0.5*Width-20)
- *'measure_length2': 区域, 相切于边界的测量区域的一半长度
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_length2', 3)
- *'measure_distance': 区域, 相邻小卡尺区域的中心距离
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_distance', 8)
- *'num_measures': 区域, 测量区域数(小卡尺个数)
- *set_metrology_object_param (MetrologyHandle, 'all', 'num_measures', 20)
- ****Edge detection:
- *'measure_sigma': 测量, 用于平滑的高斯函数的Sigma
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1)
- *'measure_threshold': 测量, 最小边缘幅度阈值
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold', 20) //***阈值30左右
- *'measure_select': 测量, 边缘端点的选择('all', 'first', 'last')
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
- *'measure_transition': ('all', 'negative', 'positive', 'uniform')
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'all')
- *'measure_interpolation': ('bicubic', 'bilinear', 'nearest_neighbor')
- set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'nearest_neighbor')
- ****Fitting the geometric shapes:
- *'min_score': 拟合, 最小分数(0.5, 0.7, 0.9)
- set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)
- *'num_instances': 拟合, 成功拟合实例的最大数量(1, 2, 3, 4)
- set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 1)
- *'distance_threshold': (0, 1.0, 2.0, 3.5, 5.0)
- set_metrology_object_param (MetrologyHandle, 'all', 'distance_threshold', 3.5)
- *'max_num_iterations': (10, 100, 1000)
- set_metrology_object_param (MetrologyHandle, 'all', 'max_num_iterations', -1)
- *'rand_seed': (0, 1, 42)
- set_metrology_object_param (MetrologyHandle, 'all', 'rand_seed', 42)
- *'instances_outside_measure_regions': ('true', 'false')
- set_metrology_object_param (MetrologyHandle, 'all', 'instances_outside_measure_regions', 'false')
- *获取计量模型的计量对象的测量区域, 未执行所以无边缘位置结果.
- get_metrology_object_measures (Contours, MetrologyHandle, Index, 'all', Row, Column) //*CHECK.
- ********************************************************************************
- *应用测量模型进行测量拟合
- apply_metrology_model (Image, MetrologyHandle)
- *获取计量模型的计量对象的测量区域, 已执行所以有边缘位置结果.
- get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row1, Column1) //*CHECK.
- *获取计量模型的计量对象的结果
- *Contour: 给定计量对象的结果轮廓
- *MetrologyHandle: 测量模型句柄
- *Index: 指定计量对象, 为all时所有计量对象的参数都被设置('all')
- *GenParamName: 通常设置为'result_type', 表示用GenParamValue返回方式和结果
- *GenParamValue: 通常设置为'all_param', 表示将所有测量参数到Parameter
- *Parameter: 返回的参数值
- *对于直线: 返回['row_begin', 'column_begin', 'row_end', 'column_end']
- *对于圆型: 返回['row', 'column', 'radius'] 或 ['x', 'y', 'radius']
- *对于椭圆: 返回['row', 'column', 'phi', 'radius1', 'radius2']
- *对于矩形: 返回['row', 'column', 'phi', 'length1', 'length2']
- get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
- *获取计量模型的计量对象的结果轮廓
- *Contour: 给定计量对象的结果轮廓。
- *MetrologyHandle: 测量模型句柄
- *Index: 指定计量对象, 为all时所有计量对象的参数都被设置('all')
- *Instance: 计量对象的实例('all')
- *Resolution: 相邻轮廓点之间的距离
- get_metrology_object_result_contour (Contour, MetrologyHandle, 'all', 'all', 1.5)
- get_metrology_object_result (MetrologyHandle, Index, 'all', 'used_edges', 'row', UsedRow)
- get_metrology_object_result (MetrologyHandle, Index, 'all', 'used_edges', 'column', UsedColumn)
- gen_cross_contour_xld (Cross, UsedRow, UsedColumn, 6, rad(45))
复制代码
|