Frangi vesselness¶
| Fact | Value |
|---|---|
| Also called | Ridge filters, Vesselness, Frangi filter |
| Status | Implemented and tested |
| Family | Texture, corners, blobs and features |
| Engine | Science engine |
| Type | Nonlinear, spatial, Hessian eigenvalue vesselness |
| Output | Image |
| Operator shown as | algorithm (exact) |
| Support radius | global |
| Code | engine/src/pixelnexus_engine/filters/ridges.py, frangi_filter |
| Operator code | engine/src/pixelnexus_engine/filters/ridges.py, ridge_representation |
| Packages | scikit-image |
| Channels | Brightness only, RGB |
Overview¶
The Frangi filter finds lines and vessels from how the brightness bends. In the middle of a dark line, the brightness bends up strongly across the line and hardly at all along it. Frangi's vesselness measure is large exactly there, and small for round blobs and flat noise. The filter tries several scales and keeps the strongest answer. It runs in the PixelNexus engine on your computer, with scikit-image.
How it works¶
- Blur the image with a Gaussian at each scale, and find the second derivatives.
- At each pixel, find the eigenvalues of the Hessian, the curvatures along and across.
- Turn them into the line measure of this filter.
- Keep the largest measure over the scales.
- Stretch the result so the strongest response is white.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(\lambda_1, \lambda_2\): The Hessian eigenvalues, |lambda_1| <= |lambda_2|
- \(R_B\): The blob ratio
- \(S\): The structure, the norm of the Hessian
- \(\beta, \gamma\): The blob and structure constants
The Hessian is the matrix of second derivatives of the image smoothed by a Gaussian of sigma. Its eigenvalues lambda_1 and lambda_2 are the curvatures along and across the strongest bend. They are sorted so that |lambda_1| <= |lambda_2|. In the middle of a dark line, the brightness bends up strongly across the line, so lambda_2 is large and positive. It hardly bends along the line, so lambda_1 is near 0. Frangi's measure is large exactly there. The ratio R_B is near 1 for round blobs, so the first factor removes them. S is large wherever there is structure at all, so the second factor removes flat noise. Where lambda_2 has the wrong sign, scikit-image clips it to 1e-10, so V is 0. The 3D plate term of the paper is 1 in 2D. The filter keeps the largest V over the scales and stretches the result so the strongest response is white.
The Hessian is the matrix of the second derivatives of the image, after a Gaussian blur of sigma. Its two eigenvalues are the curvatures along and across the direction where the brightness bends most. Sort them so that the first is the smaller in size. Across a dark line, lambda_2 is large and positive. Along it, lambda_1 is near 0.
Frangi et al. built the measure from two ratios. R_B compares the two curvatures. It is near 1 for round blobs, so the first factor removes them. S is the size of the Hessian, which is small in flat, noisy areas, so the second factor removes them. Beta and gamma set how strict each test is. In scikit-image, gamma is half of the largest S at each scale unless you set it. Where lambda_2 has the wrong sign for the ridge color, scikit-image clips it to 1e-10, so the measure is 0. The paper's third factor, for flat plates, only matters in 3D.
Kernel or operator¶
The Inspector asks the engine for the stages with the current settings. They are the Hessian with the list of scales, the eigenvalues, the line measure with its constants, and the maximum over the scales.
Algorithm¶
- Compute the Hessian with Gaussian derivatives at each scale.
- Find its eigenvalues at each pixel, sorted by size.
- Combine them into the vesselness V.
- Keep the largest V over the scales and stretch it to the full range.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Ridges ridges |
Dark ridges | Dark ridges, Bright ridges | Whether the lines to find are darker or brighter than their surroundings. Vessels in retinal photos are dark. |
Smallest scale sigmaMin |
1 | 0.5 to 20 px | The smallest Gaussian sigma. A line of width w responds most near sigma = w / 2 or a little less. |
Largest scale sigmaMax |
9 | 0.5 to 20 px | The largest Gaussian sigma. If it is below the smallest scale, only the smallest is used. |
Scale step sigmaStep |
2 | 0.5 to 10 px | The step between the scales. The defaults give 1, 3, 5, 7 and 9, the scikit-image defaults. |
Beta beta |
0.5 | 0.1 to 2 | How strongly round blobs are suppressed, through R_B = |
Gamma gamma |
0 | 0 to 200 | The structure scale, in pixel levels per pixel squared. Responses with S well below gamma are suppressed. 0 uses half of the largest S at each scale, as scikit-image does. |
Border mode border |
Reflect | Reflect 101 (default), Reflect, Replicate, Constant (zero), Wrap | How pixels outside the image are filled when the window reaches past the edge. |
Channels channelScope |
Brightness only | RGB, Brightness only | Which part of the color image the filter changes. |
Implementation¶
frangi_filter in engine/src/pixelnexus_engine/filters/ridges.py calls skimage.filters.frangi on each plane the scope names, in pixel levels from 0 to 255, with the scales, the ridge color and the border mode. Then it stretches the result so the strongest response is 255. A Gamma of 0 passes None, so scikit-image picks gamma at each scale. The Hessian comes from two passes of a Gaussian derivative of sigma / sqrt(2), so the image is blurred by sigma in all. There is no live preview. The result arrives when you click Apply.
Worked example¶
| Scales | Width 1 | Width 2 | Width 4 | Width 8 | Disk |
|---|---|---|---|---|---|
| Defaults (1 to 9) | 165 | 230 | 182 | 11 | 1 |
| Scales 1 to 3 | 165 | 230 | 182 | 17 | 1 |
| Scales 5 to 9 | 15 | 53 | 152 | 253 | 38 |
The image of the figure: four dark waves on a ground of 200, at 70 before a blur of sigma 0.6 and noise of sigma 4, and a dark disk of radius 6. The numbers are the result of the Frangi filter from 0 to 255, as the median along the middle of each wave and the value at the middle of the disk. Each result is stretched so its strongest response is 255.
Complexity¶
- Time: \(O(K N sigma)\)
- Memory: \(O(N)\)
N is the number of pixels, K the number of scales and sigma the largest scale. The Gaussian derivatives are separable, and their windows reach 8 sigma.
Artifacts and limitations¶
Limitations
- Line crossings and branch points respond weakly, since they look like blobs.
- The measure has no scale normalization in scikit-image. With many scales, wide lines respond far more weakly than thin ones, so set the smallest scale higher to find wide lines. The worked example shows it.
Artifacts
- Edges of large bright areas can show as thin double lines.
Tests¶
The filter must equal skimage.filters.frangi with the same scales, ridge color and constants, stretched and rounded. The strongest response must be in the middle of a line. Bright ridges of a negated image must give the same result as dark ridges of the image. A round blob must respond less than a twentieth of a line. The engine API tests run a job and check the stages of the representation.
References¶
- Frangi, A. F., Niessen, W. J., Vincken, K. L., and Viergever, M. A. Multiscale vessel enhancement filtering. Medical Image Computing and Computer-Assisted Intervention (MICCAI 1998), Lecture Notes in Computer Science 1496, 130 to 137, 1998. DOI 10.1007/BFb0056195.
- scikit-image documentation, skimage.filters.frangi.