<p>目前(scikit映像1.14.1),接受的答案不起作用。
以下是一个版本:</p>
<pre><code>import cv2
import matplotlib.pyplot as plt
from skimage.feature import hessian_matrix, hessian_matrix_eigvals
src_path = 'Fundus_photograph_of_normal_left_eye.jpg'
def detect_ridges(gray, sigma=1.0):
H_elems = hessian_matrix(gray, sigma=sigma, order='rc')
maxima_ridges, minima_ridges = hessian_matrix_eigvals(H_elems)
return maxima_ridges, minima_ridges
def plot_images(*images):
images = list(images)
n = len(images)
fig, ax = plt.subplots(ncols=n, sharey=True)
for i, img in enumerate(images):
ax[i].imshow(img, cmap='gray')
ax[i].axis('off')
plt.subplots_adjust(left=0.03, bottom=0.03, right=0.97, top=0.97)
plt.show()
img = cv2.imread(src_path, 0) # 0 imports a grayscale
if img is None:
raise(ValueError(f"Image didn\'t load. Check that '{src_path}' exists."))
a, b = detect_ridges(img, sigma=3.0)
plot_images(img, a, b)
</code></pre>
<p><a href="https://i.stack.imgur.com/8fwJL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8fwJL.png" alt="fundus_fig"/></a></p>
<p>图像源:<a href="https://en.wikipedia.org/wiki/Fundus_photography#/media/File:Fundus_photograph_of_normal_left_eye.jpg" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Fundus_photography#/media/File:Fundus_photograph_of_normal_left_eye.jpg</a></p>