Ridge finding as described by
C. Steger, "An unbiased detector of curvilinear structures," in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 20, no. 2, pp. 113-125, Feb. 1998, doi: 10.1109/34.659930.
This image can be produced with the following code
import matplotlib.pyplot as plt
import numpy as np
from skimage import color, data
from steger import find_ridges
image = color.rgb2gray(data.retina())[300:700, 700:900]
result = find_ridges(image, sigma=5, dark=False)
fig, (ax1, ax2) = plt.subplots(
figsize=(5, 5),
ncols=2,
gridspec_kw=dict(wspace=0.01),
sharey=True,
)
for ridge in result.ridges:
ax1.plot(ridge.x, ridge.y, ".-")
ax1.imshow(image, cmap="gray_r")
# This is a useful way to check that line points are connected in the "right
# way" i.e. they should all point in the same direction
px, py, nx, ny, eigvals, valid = result.points
ax2.imshow(image, cmap="gray_r")
angle = np.rad2deg(np.arctan2(ny, nx))
cb = ax2.quiver(
py[valid],
px[valid],
nx[valid],
ny[valid],
angle[valid],
clim=(-180, 180),
cmap="twilight",
units="xy",
)
plt.show()