<p>脊线是图像二阶导数矩阵的特征值,也称为hessian矩阵。在</p>
<p>使用以上信息,您可以使用scikit image提供的功能轻松编写脊线检测器</p>
<pre><code>from skimage.features import hessian_matrix, hessian_matrix_eigvals
def detect_ridges(gray, sigma=3.0):
hxx, hyy, hxy = hessian_matrix(gray, sigma)
i1, i2 = hessian_matrix_eigvals(hxx, hxy, hyy)
return i1, i2
</code></pre>
<p>这里,i1返回局部极大值脊线,i2返回局部极小值脊线。你可以用sigma值来寻找合适的解决方案。
示例:</p>
<p><a href="https://i.stack.imgur.com/NWSUq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NWSUq.png" alt="enter image description here"/></a></p>
<p>实际上,在Python/OpenCV中,可以执行以下操作</p>
^{pr2}$
<p><code>cv2.ximgproc.RidgeDetectionFilter_create</code>的参数包括:</p>
<pre><code>@param ddepth Specifies output image depth. Defualt is CV_32FC1
@param dx Order of derivative x, default is 1 .
@param dy Order of derivative y, default is 1 .
@param ksize Sobel kernel size , default is 3 .
@param out_dtype Converted format for output, default is CV_8UC1 .
@param scale Optional scale value for derivative values, default is 1 .
@param delta Optional bias added to output, default is 0 .
@param borderType Pixel extrapolation method, default is BORDER_DEFAULT
</code></pre>
<p>源-<a href="https://docs.opencv.org/trunk/d4/d36/classcv_1_1ximgproc_1_1RidgeDetectionFilter.html" rel="noreferrer">https://docs.opencv.org/trunk/d4/d36/classcv_1_1ximgproc_1_1RidgeDetectionFilter.html</a></p>