平滑得到的灰度直方图

Sigma := 0.3

create_funct_1d_array (GrayValues, Function) //将离散的灰度值连成函数

smooth_funct_1d_gauss (Function, Sigma, SmoothedFunction)

对平滑后的灰度直方图进行求导

derivate_funct_1d (SmoothedFunction, 'first', FirstDerivative)

zero_crossings_funct_1d (FirstDerivative, ZeroCrossings)

导数为0的点就是边缘点。但是如果直接找0点的话,会找到很多,我们不太好筛选,所以我们选择求二阶导数找最大值来筛选。先设定一个阈值,大于这个阈值的点才被定为边缘点。

MinimumMagnitudeOfSecondDerivative := 8
PositionOfSalientLine := []
for i := 0 to |ZeroCrossings|-1 by 1
get_y_value_funct_1d (SecondDerivative, ZeroCrossings[i], 'constant', Y)
if (Y > MinimumMagnitudeOfSecondDerivative)
PositionOfSalientLine := [PositionOfSalientLine,ZeroCrossings[i]]
endif
endfor

通过得到的边缘点对应的值PositionOfSalientLine算出坐标点

RowStart := floor(Row+0.5)+floor(Length1)*sin(Phi)

ColStart := floor(Column+0.5)-floor(Length1)*cos(Phi)

RowLine := RowStart-PositionOfSalientLine*sin(Phi)

ColLine := ColStart+PositionOfSalientLine*cos(Phi)

【Halcon】1D测量之二

  下面是【solution_guide_iii_a_1d_measuring.pdf】 第四章高级测量:模糊测量对象的一部分内容:

模糊测量对象是标准测量对象的扩展,可以通过特定的权重函数选择边缘和边缘对。

模糊隶属度函数可以通过位置,大小或灰度值等特征选择合适的边缘对。如例程fuzzy_measure_switch.hdev

通过算子create_funct_1d_pairs创建一个隶属度函数

    create_funct_1d_pairs ([7,9,11], [0.0,1.0,0.0], SizeFunction)

通过算子set_fuzzy_measure将一个标准测量对象转为模糊对象

SetType := 'size'\\通过边缘对包围区域的大小选择边缘对

set_fuzzy_measure (MeasureHandle, SetType, SizeFunction)

应用模糊对象进行测量

Sigma := 0.9
AmpThresh := 12
FuzzyThresh := 0.5
Transition := 'negative'
Select := 'all'
fuzzy_measure_pairs (Image, MeasureHandle, Sigma, AmpThresh, FuzzyThresh, \
Transition, RowEdgeFirst, ColumnEdgeFirst, \
AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, \
AmplitudeSecond, RowEdgeCenter, ColumnEdgeCenter, \

FuzzyScore, IntraDistance, InterDistance)

FuzzyThresh 超过给定的值 0.5的边缘对将被返回。

相关文章: