zew*_*liu 7 python opencv computer-vision
我正在尝试使用带有opencv-python的ridge/valley过滤器.我刚刚在openCV的官方网站上查看了该文档,该网站告诉我使用
out = cv.ximgproc_RidgeDetectionFilter.getRidgeFilteredImage( _img[, out] ).
但是,经过尝试,这个函数似乎在cv2(python)中不存在.有没有其他方法可以使用openCV或任何其他可用的方法来做到这一点?
脊是图像二阶导数矩阵的特征值,也称为粗糙矩阵.
使用上述信息,您可以使用scikit-image提供的功能轻松编写脊探测器
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
Run Code Online (Sandbox Code Playgroud)
这里,i1返回局部最大值脊,i2返回局部最小值脊.您可以使用sigma值来调整以获得适当的解决方案.例:
实际上,在Python/OpenCV中,你可以做这样的事情
image = cv2.imread('retina.tif')
ridge_filter = cv2.ximgproc.RidgeDetectionFilter_create()
ridges = ridge_filter.getRidgeFilteredImage(image)
Run Code Online (Sandbox Code Playgroud)
参数cv2.ximgproc.RidgeDetectionFilter_create包括:
@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
Run Code Online (Sandbox Code Playgroud)
来源 - https://docs.opencv.org/trunk/d4/d36/classcv_1_1ximgproc_1_1RidgeDetectionFilter.html