Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

On frangi

skimage.filters.frangi has five separable defects. Four are in the filter, one is inherited from hessian_matrix and is fixed in on_hessian.md. This notebook takes them one at a time: what the filter is supposed to do, what it does, the smallest example that shows the difference, and a runnable repair.

defectconsequencestate in this tree
D1the wrong-sign rejection is defeated when λ1=0\lambda_1 = 0black_ridges has no effect on an ideal ridgeresidue of #6436; repaired in frangi-fixes
D2no scale normalisation on the Hessianideal ridges never select their width; non-trivial vesselness collapses to the finest σ#7711; repaired in frangi-fixes
D3gamma=None is resolved inside the σ loopoutput depends on the order of sigmasrepaired in frangi-fixes
D4gamma=None exposes Frangi’s whole-image contrast heuristic without documenting its scopeone distant pixel changes the answerthe global cc heuristic is in Frangi; unchanged by the repairs, documented only
D5border error from the two-pass Hessiana bright rim, large relative to the output rangeon_hessian.md, fixes A and C
D6alpha is documented but inert in 2-Da parameter that does nothing, silentlya docstring line

Two code states appear through the notebook.

The notebook carries both implementations, as frangi_prefix and frangi_postfix in §1, and uses them for every result. It does not call the installed frangi for any measurement, so its answers do not depend on the installed version. One cell in §1 reports which state the installation matches.

D3 and D4 are the subject of on_meijering.md’s sibling argument: both filters let a whole-image number into the loop, but D3 is an order-dependent implementation error while D4 exposes a published global contrast heuristic without a locality contract. D6 is a documentation defect and is dealt with in one paragraph.

Coordinates are in array order throughout. All sections assume 2-D unless they say otherwise.

fatal: not a git repository (or any of the parent directories): .git

1. What frangi computes

Frangi’s filter asks, at every pixel and every scale, whether the local second order structure looks like a tube. It smooths the image with a Gaussian of width σ, takes the matrix of second derivatives — the Hessian HH — and looks at its eigenvalues λ1,λ2\lambda_1, \lambda_2, ordered so that ∣λ1∣≤∣λ2∣|\lambda_1| \le |\lambda_2|.

This section uses the 2-D specialization of Frangi’s filter. For a bright line on a dark background the cross-section curves sharply downward and the along-line direction is flat, so λ2≪0\lambda_2 \ll 0 and λ1≈0\lambda_1 \approx 0. For a blob both curve, so λ1≈λ2\lambda_1 \approx \lambda_2. In 3-D, the paper also uses the third eigenvalue and a plate-sensitivity ratio RAR_A; that factor is absent from the 2-D expression below. Frangi et al. Frangi et al., 1998 turn the 2-D case into two dimensionless numbers and one absolute one:

Rb=∣λ1∣∣λ2∣,S=∥H∥F=λ12+λ22,R_b = \frac{|\lambda_1|}{|\lambda_2|}, \qquad S = \|H\|_F = \sqrt{\lambda_1^2 + \lambda_2^2},

and combine them as

V=exp⁡ ⁣(−Rb22β2)⏟blobness⋅(1−exp⁡ ⁣(−S22c2))⏟structuredness,\mathcal{V} = \underbrace{\exp\!\left(-\frac{R_b^{2}}{2\beta^{2}}\right)}_{\text{blobness}} \cdot \underbrace{\left(1 - \exp\!\left(-\frac{S^{2}}{2c^{2}}\right)\right)}_{\text{structuredness}} ,

with the convention that V=0\mathcal{V} = 0 when the relevant eigenvalue has the wrong sign for the polarity being sought. In 2-D this is λ2\lambda_2; in 3-D the paper’s branch checks the relevant λ2\lambda_2 and λ3\lambda_3 signs. The final answer is the maximum of V\mathcal{V} over a list of scales.

The paper calls the structuredness threshold cc, not γ\gamma. The scikit-image API names its corresponding argument gamma; this notebook uses cc for the paper’s quantity and reserves γL\gamma_L for Lindeberg’s derivative normalization exponent.

Three things about that expression drive everything below.

1.1 The two code states

The notebook carries both implementations in full, so it does not depend on the installed frangi. frangi_prefix is the released filter. frangi_postfix is the same filter after the three repairs. Both handle 2-D and 3-D.

The reference photograph and the σ list used throughout.

The installed version matches one state and not the other. The notebook uses the two implementations above for every later result, so the match below is informational only.

installed scikit-image 0.27.0rc2.dev0
   installed matches pre-fix  : max |difference| = 0.00e+00
   installed matches post-fix : max |difference| = 5.36e-01

2. D1 — black_ridges has no effect on an ideal ridge

Frangi’s rule is that a wrong-sign eigenvalue means “not a vessel”. In the paper this is an explicit zero branch in the 2-D and 3-D equations. The clipped-denominator mechanism below is the pre-fix implementation, not the paper’s derivation. If λ2\lambda_2 has the wrong sign, the intended response is zero; the implementation only gets that result when the other eigenvalue does not also clip to zero.

(lambda2,) = np.maximum(eigvals[1:], 1e-10)
r_b = abs(lambda1) / lambda2

The clip makes RbR_b enormous — provided the numerator is not also zero. At the centre of a straight ridge the along-ridge curvature vanishes exactly, so λ1=0\lambda_1 = 0, and 0/10−10=00 / 10^{-10} = 0, not ∞\infty. Blobness becomes exp⁡(0)=1\exp(0) = 1: full marks, for a ridge of precisely the wrong polarity.

value at the ridge centre, pre-fix frangi; `black_ridges=True` asks for DARK ridges
   black_ridges=True   0.864665
   black_ridges=False  0.864665

the two outputs are identical everywhere: True

The mechanism, read off the eigenvalues across the ridge.

<Figure size 1265x308 with 3 Axes>
at the ridge centre:  lambda1 = 0.000e+00   lambda2 = -3.928e-02
  clipped denominator = 1.0e-10
  R_b = 0.0000   blobness = 1.0000   (should be 0)

2.1 How wide is the leak?

The rejection survives only while ∣λ1∣|\lambda_1| is large enough that ∣λ1∣/10−10|\lambda_1|/10^{-10} is large. Solving exp⁡(−Rb2/2β2)>θ\exp(-R_b^2/2\beta^2) > \theta for β=1/2\beta = 1/2 gives the threshold on ∣λ1∣|\lambda_1| below which blobness exceeds θ\theta — that is, below which a wrong-polarity pixel is scored as a vessel.

Loading...

Those thresholds are minute, so the temptation is to say the leak cannot happen on real data. It has to be checked at every scale rather than one, because ∣λ1∣|\lambda_1| shrinks as σ grows.

Loading...
straight synthetic ridges, |lambda1| at the centre:
   width  1.0: 0.00e+00
   width  3.0: 0.00e+00
   width  8.0: 0.00e+00

So the leak is not quite absent from photographs. On camera it is silent at σ = 1 through 7 and fires at σ = 9, where a single pixel is scored above 0.5 and two above 0.01 out of 65536 — because ∣λ1∣|\lambda_1| there has fallen to 1.4×10−111.4\times10^{-11}, below the threshold in the table. A σ = 3 scan alone would have reported nothing and invited the stronger claim.

The honest summary is that D1 is vanishingly rare on photographs and universal on clean ridges: every exactly straight ridge has λ1=0\lambda_1 = 0 along it, so every one of them leaks completely. That is every construction anyone would write a unit test or a documentation example around. skimage’s own test_ridges.py does not catch it: its polarity tests compare f(dark, black_ridges=True) against f(bright, black_ridges=False), a symmetry that holds trivially because the implementation negates the image, and never assert that a ridge of the wrong polarity scores zero.

2.2 The fix: test the sign, do not divide by it

Both ITK and the jerman filter proposed in #8074 reject by an explicit comparison rather than by arranging for a division to explode. ITK’s HessianToObjectnessMeasureImageFilter is the clearest statement of it:

if ((m_BrightObject && sortedEigenValues[i] > 0.0) ||
    (!m_BrightObject && sortedEigenValues[i] < 0.0))
  { signConstraintsSatisfied = false; break; }

The same thing in NumPy, keeping the division away from the masked pixels:

Loading...

The right-polarity answer is untouched; the wrong-polarity answer goes from the largest value the filter can produce to zero. That ceiling is worth naming: with γ=12max⁡xS\gamma = \tfrac12\max_\mathbf{x} S the structuredness gate at the most curved pixel is 1−exp⁡(−S2/2γ2)=1−e−2≈0.86471 - \exp(-S^2/2\gamma^2) = 1 - e^{-2} \approx 0.8647, so a single-scale frangi with the default γ cannot exceed that. A wrong-polarity ridge was scoring exactly it.

3. D2 — no scale normalization for ideal ridges

frangi is documented as returning the “maximum of pixels across all scales”, which allows different scales to win. On an ideal straight ridge, however, in the pre-fix code SS falls with σ while blobness stays pegged at 1, so the unnormalised structuredness term cannot select the ridge width. That is the scale-normalisation problem reported by issue #7711. The paper itself says that its maximum occurs at a scale approximately matching vessel size; the stronger finest-scale result below is for the ideal ridge model and this implementation. The argument also needs care: RbR_b is invariant under scaling the Hessian, not under changing σ, which re-smooths the image and can move RbR_b. Scale selection through blobness is therefore possible in non-ideal structures.

3.0 Why SS falls on a Gaussian ridge

A unit-height Gaussian ridge of width ww, I0(x)=exp⁡ ⁣(−x2/(2w2))I_0(x) = \exp\!\bigl(-x^2/(2w^2)\bigr), smoothed by a Gaussian of width σ is again Gaussian, with variance v=w2+σ2v = w^2 + \sigma^2 and peak height w/vw/\sqrt{v}:

L(x,σ)=wv exp⁡ ⁣(−x22v).L(x, \sigma) = \frac{w}{\sqrt{v}}\, \exp\!\Bigl(-\frac{x^2}{2v}\Bigr).

The cross-ridge second derivative on the axis is therefore

∂xxL(0,σ)=−wv3/2=− w (w2+σ2)−3/2,\partial_{xx} L(0, \sigma) = -\frac{w}{v^{3/2}} = -\,w\,(w^2 + \sigma^2)^{-3/2},

which is strictly decreasing in σ for every w>0w > 0. Along the ridge ∂yyL=0\partial_{yy} L = 0, so S=∣∂xxL∣S = |\partial_{xx} L| and the same falloff holds for Frangi’s Hessian norm. Multiplying by σ2γL\sigma^{2\gamma_L} is exactly Lindeberg’s normalisation of a second derivative — the same factor on_meijering.md §5.1 derives — and is the reason any finite scale can win.

That ∂yyL=0\partial_{yy} L = 0 is also what pegs blobness at 1: it makes λ1=0\lambda_1 = 0, hence Rb=0R_b = 0, at every scale rather than at the one scale §2 happened to sample. Both statements are checked below.

Correlation is the wrong instrument here and it is worth saying why, because it looks like strong evidence. Two curves that both decay smoothly correlate at better than 0.99 whatever their exponents, so a high correlation cannot distinguish the predicted law from a wrong one. The largest relative deviation can.

Loading...

Every candidate correlates above 0.99, the wrong ones included. The deviation column separates them: sub-1% for the predicted law against tens to hundreds of percent for the rest. So check the law on every width with that, and check the monotonicity claim on every width too rather than on one.

Loading...

SS falls monotonically at every width, tracks the continuous law to within a percent, and λ1\lambda_1 is zero — not small, zero — at every scale on the scan, so blobness never leaves 1. On an ideal ridge the only σ-dependence left really is SS, which is what makes the pre-fix filter’s maximum over scales collapse onto the finest one.

<Figure size 1265x330 with 3 Axes>

The left panel is the pre-fix filter: three ridges of quite different width, three curves that all peak at the smallest scale on the scan. The other two panels apply Lindeberg’s γ-normalisation, a factor σ2γ\sigma^{2\gamma} on a second derivative. The peaks then land where the theory says.

Loading...

σ^1.5 selects the ridge’s own width and σ^2 selects w2w\sqrt2 — exactly the two calibrations on_meijering.md §5 derives from Lindeberg Lindeberg, 1998 §5.6.1, now measured on Frangi’s SS rather than on Meijering’s eigenvalue. The choice of exponent is the same open question in both filters.

On a photograph the same collapse shows up wherever vesselness is non-trivial. Below a small floor the argmax over scales is noise among values near zero; above it, without a σ power, the finest scale wins every time under the usual γ (half the Hessian norm at sigmas[0]).

camera, γ from sigmas[0]=1: 10.1% of pixels have V > 0.01
  of those, won by σ=1: 100.0%
  of those, won by any larger σ: 0.0%

Two caveats keep this from being “every pixel, every γ”, and the second is worth measuring rather than conceding. First, among pixels with V≈0V \approx 0 the argmax is meaningless, and a majority of the frame sits there. Second, if γ is driven small enough that the structuredness gate saturates at several scales, the gate stops discriminating and blobness decides instead — so a coarser scale can win. Shrinking γ below the default shows exactly that.

Loading...

At the default γ the finest scale takes the whole live set. Divide γ by a thousand and the gate is saturated almost everywhere, blobness takes over, and σ = 9 wins a tenth of a much larger live set. So the defect is not that coarser scales are unreachable in floating point; it is that the filter never selects a ridge’s own width, and that non-trivial vesselness under the default γ collapses to the finest scale.

3.1 What the paper asks for

Frangi et al. define their derivatives in normalised form,

∂∂xL(x,s)=sγ L(x)∗∂∂xG(x,s),\frac{\partial}{\partial x} L(\mathbf{x}, s) = s^{\gamma}\, L(\mathbf{x}) * \frac{\partial}{\partial x} G(\mathbf{x}, s),

so a second derivative carries s2γLs^{2\gamma_L} and the Hessian is scaled as a whole. This γL\gamma_L is the derivative-normalization exponent, not scikit-image’s gamma argument. The API argument corresponds to Frangi’s cc, the structuredness threshold. The pre-fix code applies no derivative factor at all, which is γL=0\gamma_L = 0 — a boundary case for the ideal ridge model, where no finite scale is selected. Issue #7711 reports the symptom directly: “Due to the missing scale corrections only the smallest scale affects the filter output.”

The repair is one multiplication, and it belongs on the Hessian so that both RbR_b and SS see a consistently scaled matrix.

The same statement holds for the whole vesselness rather than on SS alone. The structuredness threshold cc has to be chosen so the gate does not saturate: once it reaches 1 at several scales the maximum is a tie, and max then returns whichever came first, which says nothing about scale selection.

Loading...

The width-6 ridge is won by σ = 1 with no exponent, by σ = 6 with σ1.5\sigma^{1.5}, and by σ = 8 with σ2\sigma^{2} — the same three answers as the table above, now with the blobness factor and the gate included, and with the tie count confirming the winner is unique.

4. D3 — the answer depends on the order of sigmas

In the pre-fix code, gamma=None is resolved with the assignment inside the scale loop:

for sigma in sigmas:                       # <- the loop
    ...
    s = np.sqrt((eigvals**2).sum(0))       # the Hessian norm
    if gamma is None:
        gamma = s.max() / 2                # rebinds the local name
        if gamma == 0:
            gamma = 1
    ...

On the first iteration the test is true and gamma becomes a number. On every later iteration it is false. So γ is half the largest Hessian norm at sigmas[0], and since §3 established that SS falls with σ, the number depends strongly on which scale happens to be written first.

γ spans a factor of 130 across sigmas = (1, 3, 5, 7, 9)
<Figure size 616x308 with 1 Axes>

Three ridges of different width, the same three scales, written twice.

<Figure size 1265x275 with 4 Axes>
Loading...

Ascending, the filter reports one vessel: the narrow ridge scores 0.86 and the widest 0.015, which reads as “not a vessel”. Descending, all three saturate at 1.0 — and so, as the profile shows, does most of the background between them. These are two different answers to which of these is a vessel, and the second barely discriminates at all.

If the mechanism above is right, two orderings agree exactly when they share a first element: six permutations, three predicted classes.

3 distinct outputs from 6 permutations; total response spans a factor of 28
Loading...

4.1 The promise this breaks

Two documented contracts, both in frangi’s own docstring. The return value is

out : Filtered image (maximum of pixels across all scales).

A maximum over a collection does not depend on the order of the collection, and sigmas is documented as “Sigmas used as scales of filter” with no hint that order matters. And the default γ is

The default, None, uses half of the maximum Hessian norm.

Half of the maximum Hessian norm, not half of the maximum at one arbitrary member of sigmas. Read literally, the docstring already describes the fix.

'half of the maximum Hessian norm' over sigmas=(1, 3, 5, 7, 9): 0.184388
what frangi actually uses, per first sigma:
   sigmas[0] = 1: 0.184388   <- matches the docstring
   sigmas[0] = 3: 0.017605
   sigmas[0] = 5: 0.004892
   sigmas[0] = 7: 0.002263
   sigmas[0] = 9: 0.001418

4.2 The fix: resolve γ before the loop

Vesselness splits cleanly at γ, so the scale loop can compute everything else first — at one Hessian per σ, the same number the pre-fix loop performs.

worst max|difference| over all six permutations of (1, 3, 5)
   pre-fix 0.9942
   hoisted 0.0000

hoisted vs pre-fix on the ascending list: 0

On an ascending list the hoisted version reproduces the pre-fix output exactly, because §3 showed SS falls with σ, so the maximum over all scales is attained at min(sigmas), which for a sorted list is also sigmas[0]. That ceases to be true once D2 is fixed, and §10 returns to the consequence.

5. D4 — γ = None is a whole-image statistic

Fixing the order (§4) does not make the filter local. In the post-fix code, gamma=None is a maximum over every scale, and in the pre-fix code it is a maximum over the first scale; either way it is a maximum over every pixel, so a single bright speck anywhere in the frame sets the contrast reference for the whole image. Frangi explicitly describes cc as depending on the image grey-scale range and recommends half the maximum Hessian norm. The global statistic is therefore part of the published heuristic; the issue here is that the API exposes it as gamma=None without documenting the non-local effect. on_meijering.md §1 uses the same two probes.

Loading...

sato is local under both probes, as a filter should be. The post-fix frangi is not, and stops being non-local the moment γ is given explicitly — which identifies γ as the sole cause. D4 is not one of the three repairs: the post-fix default is a maximum over every scale, which is still a whole-image statistic.

Two cautions about reading that table. The margin matters: if it is smaller than the widest kernel support, the crop probe measures the border defect of §6 rather than non-locality. And the crop probe can read 0.00% for frangi even at gamma=None — that is not evidence of locality, only evidence that this crop happened to keep the pixel that sets the maximum. A probe returning zero proves nothing on its own; the far-field column is the one doing the work here.

sato crop_change at margin=20: 4.41%
sato crop_change at margin=40: 0.00%

There is no repair that keeps gamma=None and restores locality, because the default is defined as an image-wide statistic. The honest options are to document it, or to give γ a local meaning, and only the first is a bug fix. on_meijering.md faces the same wall for the same reason.

5.1 How much does γ disturb the comparison between scales?

It is tempting to say a single frozen γ rescales every scale alike and so leaves the cross-scale comparison intact, unlike a per-scale divisor. That is the wrong reason for the right distinction. The structuredness gate is not linear in SS, and different scales arrive with different SS, so changing γ reweights the scales against each other even when one γ is used for all of them.

Loading...
fraction of pixels where the winning sigma changes
  all pixels, frozen γ (sigmas[0]=1 vs 9) : 5.7%
  all pixels, frozen γ vs γ per scale     : 43.0%
  among V > 0.01, frozen γ reorder   : 18.1%  (10.1% of the image)
  among V > 0.01, vs γ per scale     : 44.6%

The distinction is quantitative, not categorical. All-pixel argmax counts are diluted by the near-zero background, where the winning scale is noise among values close to zero; restricting to V>0.01V > 0.01, about a tenth of the frame under the usual γ, is the comparison that bears on vessel selection. On that set, reordering sigmas moves the winning scale at 18% of the pixels with V>0.01V > 0.01, and a per-scale γ moves it at 45% of the same set — against 6% and 43% when the background is allowed to dilute both. A frozen γ is the milder of the two, not an innocent one, and restricting to the live set makes the reordering defect three times larger, not smaller.

6. D5 — the border rim

The last defect is not frangi’s own. hessian_matrix filters each axis in turn with a Gaussian and then differentiates, so the boundary extension is applied to an already-smoothed array rather than to the image; on_hessian.md diagnoses it and gives fixes A and C. The consequence in frangi is a bright rim.

A reference that must agree: extend the image symmetrically, filter, and crop back. With mode='reflect' an exact implementation gives the same answer on the shared pixels.

released Hessian       largest disagreement anywhere: 0.769
Hessian fixes A + C    largest disagreement anywhere: 0
Loading...
<Figure size 1166x374 with 3 Axes>

With the released Hessian the disagreement is confined to a rim: about 77% of the output range at the outermost pixel, an order of magnitude less one pixel in, and below 1% by the third. With fixes A and C it is zero — not small, zero to floating point — at every depth, which is the result on_hessian.md reports for frangi, sato and hessian together. Nothing in frangi itself needs to change.

7. D6 — alpha does nothing in 2-D

The plate-sensitivity factor 1−exp⁡(−Ra2/2α2)1 - \exp(-R_a^2/2\alpha^2) needs three eigenvalues. In 2-D the factor does not appear: the pre-fix code sets r_a = np.inf, and the post-fix code has no 2-D plate term. Either way alpha cannot affect the result. The docstring describes alpha without qualification. D6 is present in both states, so the post-fix filter is shown.

Loading...

Exactly zero in 2-D, non-zero in 3-D. This is a docstring fix, not a code fix: add “has no effect for 2-D images” to the alpha entry.

8. How often, and how big

Three greyscale images from skimage.data, downsampled so the longest side is about 200 px. mean ratio is the mean of the reversed-sigmas output over the mean of the ascending one. top 1% overlap is the Jaccard index of the two sets of pixels above each run’s own 99th percentile — agreement about which pixels respond most, with each run allowed its own scale.

Loading...

Every image is affected by D3 and D4, and D3’s effect is not a rescaling that a downstream threshold could absorb: the strongest-responding 1% of pixels under the two orderings barely overlap.

D1 is not in this table because a corpus of photographs is the wrong place to measure it: §2.1 found it firing on two pixels of one image at one scale. It is a property of exact ridges, so it is measured where it lives.

Loading...

9. Comparators

No other implementation makes all of these choices, and each of the four in-filter defects is contradicted by at least one of them.

implementationwrong-sign rejection (D1)σ normalisation (D2)structuredness threshold cc / order (D3, D4)
Frangi et al. (1998)explicit sign branch in Eqs. (13) and (15)derivatives defined as sγL L∗∂Gs^{\gamma_L}\,L * \partial Gcc is “half the value of the maximum Hessian norm”
ITK HessianToObjectnessMeasureImageFilterexplicit signConstraintsSatisfied test, then zeroSetNormalizeAcrossScale(true) on the Hessian filter — Lindeberg γ = 1a fixed user parameter, never computed from the image; Gamma == 0 disables the term
DIPlib FrangiVesselness—a single-scale primitive that leaves eq. (2) to the caller: scale the input by σ² and its c is the paper’s (§9.1)not image-derived
Jerman’s own MATLAB (source)explicit Lambda3 <= 0 testc = sigma.^2; Hxx = c*Hxx; ... — σ² on the Hessiantau * max(Lambda3(:)), per scale
skimage PR #8074 (jerman)explicit lambda3 <= eigval_tol testnone — drops the reference’s σ², but the response is ratio-only so this is inerttau * lambda3.max(), per scale, inside the loop
OpenCV ximgproc::RidgeDetectionFilter—single fixed ksize, no scale loop—
skimage frangi, pre-fixclipped divide, defeated when λ1=0\lambda_1 = 0nones.max()/2 at sigmas[0], frozen
skimage frangi, post-fixexplicit sign test, as ITK and Jermanσ2\sigma^2 on the Hessian normgamma=None resolved over every scale; a fixed user parameter when given

Two things follow from that table.

ITK is the cleanest contradiction of D3 and D4 together: γ is a parameter the caller sets, so there is no image statistic in the loop and no order to depend on. Everyone who does derive a threshold from the image — Jerman, and the proposed skimage port of it — derives it per scale, which is on_meijering.md’s defect rather than this one. Nobody freezes one at an arbitrary scale.

The proposed jerman filter is worth flagging on its own account, though only for half of what it first appears. Its reference implementation multiplies the Hessian by sigma.^2 and the PR does not, which reads as D2 arriving in a new filter. It is not a response change while the eigenvalues stay clear of the PR’s absolute eigval_tol: jerman_vesselness.md §3 shows that the response depends on its eigenvalues only through their ratio. The omission is therefore conditionally inert, not unconditionally so.

What does carry over is the other half: jerman recomputes tau * lambda3.max() inside the scale loop, so it would be a second filter with meijering’s non-locality. Measured there at 92% under this section’s far-field probe.

max |ascending - reversed| over sigmas
  meijering       0.0000
  sato            0.0000
  frangi pre-fix  0.9994
  frangi post-fix 0.0000

9.1 Measured against ITK and DIPlib

The table above is read from documentation and source. This section runs the two libraries. It needs diplib and itk, neither of which is a dependency of anything else here.

DIPlib -- a quantitative image analysis library
Version 3.6.1 (Jun 27 2026)
For more information see https://diplib.org

Both are single-scale and neither derives c from the image, so the comparable call passes one σ and an explicit γ.

Equation (2) folds the scale normalisation into the definition of the derivative, so the HH of eq. (12) already carries σ2\sigma^2, SS is already normalised, and cc is a threshold on that. Our gamma is that cc. The question for each library is only where it puts eq. (2). ITK has it as a switch, SetNormalizeAcrossScale; with the switch on, its γ is ours with no factor anywhere. DIPlib leaves it to the caller — which is why its response falls monotonically with σ — so hand it the image times σ2\sigma^2 and its cc is ours too.

Dividing cc by σ2\sigma^2 instead would be the same arithmetic, since scaling the input scales SS and leaves the blobness ratio alone. Scaling the input is the better statement of it: one threshold, both sides normalised.

Loading...

The median is zero and only a fraction of a per cent of pixels move by more than 1%: the bulk agrees exactly, and the residue is the handful of pixels where an eigenvalue sign is near-degenerate, plus each library’s own Gaussian. frangi is the same filter these two are.

9.2 Three independent readings of the exponent

The matching above assumed the exponent is 2. That is testable, and all three ways of asking put it at exactly that. The scan below divides cc rather than scaling the input, because a scan wants one thing varying: dividing cc by σp\sigma^p is the same arithmetic as scaling the input by σp\sigma^p, and reads better when pp is not 2.

Loading...
Loading...

So: DIPlib’s own responses pick out 2.0 with a sharp minimum; ITK’s NormalizeAcrossScale switch is indistinguishable from dividing cc by σ2\sigma^2; and ITK’s normalised Hessian is its plain one times exactly σ2\sigma^2. The exponent in §10’s repair is not a preference.

10. Ways forward

Each defect has a small repair. Put together they are one function, and the order in which they are adopted matters — §10.2.

10.1 The four repairs, in one implementation

Loading...

10.2 D2 and D3 must be fixed together

§4.2 showed that hoisting γ is a silent no-op for an ascending sigmas, because the largest Hessian norm sits at the smallest σ. Applying the σ power destroys that property: σ2γLS\sigma^{2\gamma_L} S peaks wherever the image’s dominant structure lives, which need not be the finest scale.

Loading...

With power=0 the peak is at σ = 1 on every image, so sigmas[0] and the true maximum coincide for a sorted list and the ordering bug is invisible. With power=2 they part company on some images. Fixing D2 alone would therefore make D3 worse — the frozen γ would be taken from a scale that is no longer even close to the maximum. D3 is the cheaper fix and should land first, or in the same change.

10.3 What the repairs cost

Loading...

D1 and D3 together cost nothing in time — the same number of Hessian evaluations — and change the photograph’s output by about 3×10−103\times10^{-10} on an ascending sigmas list. The residue is not exactly zero, and §2.1 says why: it is the D1 leak firing at σ = 9 on the two pixels where ∣λ1∣|\lambda_1| has fallen below the threshold. The change is that small because those pixels also carry a tiny SS, so the structuredness gate had nearly closed on them anyway. On synthetic ridges the same two fixes change the answer completely, which is the point.

D2 changes everything, on every image, by design: it is the difference between a filter that can select a ridge’s width and one that collapses non-trivial vesselness onto the finest scale. That is a behaviour change to announce, not a silent bug fix, and it is what #7711 is asking for.

11. What not to do

Do not recompute γ at every scale

It removes the order dependence and it is the smaller diff. It also hands every scale a different divisor, which §5.1 measured as moving the winning scale at 45% of the pixels with V>0.01V > 0.01, against the 18% of that same set moved by the order effect it repairs — a larger defect in exchange for a smaller one, and precisely the one on_meijering.md is about. The far-field probe confirms it stays non-local.

γ per scale: far field 82.55%
brighten one pixel at (0, 0); winning sigma more than 100 px away
  γ per scale   changed for 19.9% of far pixels
  γ hoisted     changed for 0.0% of far pixels

Do not just sort sigmas inside the function

Sorting makes the output a function of the set again, satisfying the docstring in one line. It also promotes the pre-fix accident — “use the smallest scale’s contrast reference” — into a decision, without anyone deciding it. And §10.2 shows it stops being equivalent to the docstring’s own wording as soon as D2 lands.

Do not read D1 as harmless because photographs are nearly unaffected

§2.1 found two leaking pixels in 65536, at one scale of one photograph. That is a statement about photographs, not about the filter. Every ridge with a straight segment has λ1=0\lambda_1 = 0 along it, exactly, and those are the structures frangi exists to find; on them the leak is total, not marginal. The defect is narrow in the space of images and central in the space of ridges.

The near-miss is itself a warning about method. A single-scale census said zero and would have supported “never”; the scan over sigmas found the exception, because ∣λ1∣|\lambda_1| falls as σ grows. Any claim of the form “this cannot happen on real data” needs the sweep, not the sample.

Do not treat D5 as a frangi bug

The rim in §6 is hessian_matrix’s, shared with sato and hessian, and fixing it inside frangi would leave the other two wrong. on_hessian.md fixes A and C remove it at source, and §6 measures them doing so.

12. Summary

defectwhat breaksevidencerepair
D1black_ridges is inert on an ideal ridge; wrong-polarity ridges score the filter’s maximum§2, identical arrays for both settings; §2.1 leak census over σ; §8 polarity tableexplicit sign test, as ITK and Jerman do
D2ideal ridges never select their own width under the pre-fix unnormalised structuredness term; non-trivial vesselness collapses to the finest σ in the tested regime§3, analytic falloff; high-VV photo scan; peaks under Lindeberg powersσ2γL\sigma^{2\gamma_L} on the Hessian; #7711
D3output depends on the order of sigmas§4, three permutation classes keyed by sigmas[0]resolve γ before the loop
D4gamma=None makes output depend on pixels arbitrarily far away§5, far-field probe, zero once gamma is explicitdocument the published global-cc heuristic, or require a local threshold
D5a bright rim, large relative to the output range§6, disagreement with a once-extended referenceon_hessian.md fixes A and C
D6alpha is documented and inert in 2-D§7, exactly zero difference in 2-D, non-zero in 3-Done docstring line

The repairs above are implemented in the frangi-fixes branch, and frangi_postfix in §1 is their transcription. The pre-fix transcription is frangi_prefix. The notebook runs against either installation and gives the same result, because every measurement comes from one of those two functions. §1’s state cell reports which of the two the installed frangi matches.

Recommended order. D3 first: it is one line, it is exactly back-compatible for sorted sigmas, and it is a prerequisite for D2 behaving sensibly. Then D1 and D6, both small and both fixing a stated contract. Then D2 as an announced behaviour change, with the exponent chosen deliberately. on_meijering.md §8 separates the detection map from the width map, and §9 compares the choice with ITK and DIPlib: the detection map takes sigma**2 in both filters, and gamma = 3/4 is a width-map calibration. The two filters answer the same question the same way. D4 is documentation. D5 belongs to hessian_matrix.

Limits. Three 2-D greyscale images from skimage.data, downsampled to about 200 px; sigmas = (1, 3, 5, 7, 9), mode='reflect', default beta; permutation scans use the first three scales, not the full list. The scale- selection measurements in §3 use ideal Gaussian ridges, where λ1\lambda_1 vanishes exactly; curved and finite-length ridges are not tested, and the D1 leak census in §2.1 covers those five σ on one photograph, so “vanishingly rare” is a statement about that scan and not a bound. 3-D frangi appears only in §7 — D1 and D3 apply there by inspection of the shared code path, but that is a reading rather than a measurement here.

The notebook was executed against two installations of scikit-image: a pre-fix build at aac0f792a and the repaired frangi-fixes tip at 275a586a3. Both runs give the same output, cell for cell, because every result comes from frangi_prefix or frangi_postfix.

scikit-image 0.27.0rc2.dev0
References
  1. Frangi, A. F., Niessen, W. J., Vincken, K. L., & Viergever, M. A. (1998). Multiscale vessel enhancement filtering. In Lecture Notes in Computer Science (pp. 130–137). Springer Berlin Heidelberg. 10.1007/bfb0056195
  2. Lindeberg, T. (1998). Edge Detection and Ridge Detection with Automatic Scale Selection. International Journal of Computer Vision, 30(2), 117–156. 10.1023/a:1008097225773