刻度线在图像中的分布比较特殊,因为刻度线通常只占据了几个像素宽度,对应剖面线灰度值在几个像素内发生急剧变化 ,measure_projection (Image, MeasureHandle, GrayValues),如下图所示
对应灰度值一阶导数由一下算子计算
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)
*
* Select the positions of those minima (i.e., positions at which the second derivative is positive)
* where the smoothed gray value profile has a high curvature, i.e., where the second derivative
* has a large absolute value. This criterion ensures that only salient lines are selected.
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