Filter Image Using Frangi
SUMMARY
Filter Image Using Frangi applies Frangi vesselness filter to enhance tubular structures.
Frangi filter is designed to detect vessel-like structures in medical images, fingerprints, and other images with elongated features. This multi-scale filter uses eigenvalue analysis of the Hessian matrix to identify tubular structures while suppressing plate-like and blob-like structures. It's particularly effective in retinal imaging, angiography, and neuroimaging applications.
Use this Skill when you want to enhance and detect vessel-like tubular structures in biomedical images.
The Skill
from telekinesis import pupil
vessels = pupil.filter_image_using_frangi(
image=image,
scale_start=1,
scale_end=10,
scale_step=2,
alpha=0.5,
beta=0.5,
gamma=None,
detect_black_ridges=True,
border_type="reflect",
constant_value=0.0,
)Example
Input Image

Original grayscale image with vessel structures (normalized to 0-1 range)
Output Image

Vesselness map highlighting tubular structures
The Code
from telekinesis import pupil
from datatypes import datatypes, io
from loguru import logger
# Load the grayscale image
DATA_DIR = pathlib.Path("path/to/telekinesis-data")
# Load image
filepath = str(DATA_DIR / "images" / "tablets_arranged.jpg")
image = io.load_image(filepath=filepath, color_model='l')
# Apply Frangi filter
vessels = pupil.filter_image_using_frangi(
image=image,
scale_start=6,
scale_end=10,
scale_step=1,
alpha=0.5,
beta=0.5,
gamma=None,
detect_black_ridges=True,
border_type="reflect",
constant_value=0.0,
)
logger.success(f"Applied Frangi filter with vessels shape as {vessels.to_numpy().shape}")The Explanation of the Code
The Frangi filter is a multi-scale vesselness filter designed to enhance tubular structures such as blood vessels, ridges, or elongated fibers. It operates by analyzing the second-order derivatives of the image intensity using the Hessian matrix and identifying structures that exhibit vessel-like eigenvalue patterns.
The code begins by importing the required modules. These imports provide access to the Pupil SDK, numerical utilities for preprocessing, and optional logging.
from telekinesis import pupil
from datatypes import datatypes, io
from loguru import loggerThe input image is loaded as a grayscale image, which is a strict requirement for Frangi filtering. Color images must be converted to grayscale before applying the filter.
# Load the grayscale image
DATA_DIR = pathlib.Path("path/to/telekinesis-data")
# Load image
filepath = str(DATA_DIR / "images" / "tablets_arranged.png")
image = io.load_image(filepath=filepath, color_model='l')The Frangi filter operates across multiple scales to detect tubular structures of varying widths. It uses the eigenvalues of the Hessian matrix to identify vessel-like structures, combining responses across scales to handle vessels of different thicknesses.
scale_start, scale_end, and scale_step define the range of vessel widths to detect. The filter analyzes the image at each scale in this range and combines the responses, allowing detection of vessels from thin capillaries to thick arteries.
alpha controls sensitivity to blob-like structures. Lower values make the filter more selective for true tubular structures rather than blob-like objects.
beta controls sensitivity to tubular structures. Higher values increase sensitivity to elongated, vessel-like features while suppressing non-tubular structures.
gamma suppresses background noise (computed automatically when set to None). When explicitly set, it controls the sensitivity to background intensity variations, helping distinguish vessels from noise.
detect_black_ridges selects whether vessels appear darker or brighter than the background. Set to True for dark vessels on bright backgrounds (common in medical imaging), False for bright vessels on dark backgrounds.
border_type and constant_value control boundary handling during filtering, affecting how the Hessian matrix is computed near image edges where derivatives may be undefined.
The Frangi filter is applied using the filter_image_using_frangi Skill. The filter evaluates vesselness at each scale and retains the maximum response per pixel.
vessels = pupil.filter_image_using_frangi(
image=image,
scale_start=6,
scale_end=10,
scale_step=1,
alpha=0.5,
beta=0.5,
gamma=None,
detect_black_ridges=True,
border_type="reflect",
constant_value=0.0,
)
logger.success(f"Applied Frangi filter with vessels shape as {vessels.to_numpy().shape}")The output is a vesselness map, where higher values correspond to stronger tubular structure responses. The original image remains unchanged.
Running the Example
Runnable examples are available in the Telekinesis examples repository. Follow the README in that repository to set up the environment. Once set up, you can run this specific example with:
cd telekinesis-examples
python examples/pupil_examples.py --example filter_image_using_frangiHow to Tune the Parameters
The filter_image_using_frangi Skill has 9 parameters:
scale_start (default: 1):
- The minimum scale (sigma) for structure detection
- Typical range: 1-5
- Determines the smallest vessel width to detect
scale_end (default: 10):
- The maximum scale (sigma) for structure detection
- Typical range: 5-20
- Determines the largest vessel width to detect
scale_step (default: 2):
- The step size between scales
- Smaller steps provide finer scale resolution but are slower
- Typical range: 1-5
alpha (default: 0.5):
- The weight for the blobness measure
- Increase to emphasize blob-like structures
- Typical range: 0.1-2.0
beta (default: 0.5):
- The weight for second-order structureness
- Increase to emphasize tubular structures
- Typical range: 0.1-2.0
gamma (default: None):
- The weight for background suppression
- If None, computed automatically
- Typical range: 0.1-2.0
detect_black_ridges (default: True):
- Whether to detect dark ridges (vessels) instead of bright
- Set True for dark vessels on bright background
border_type (default: "reflect"):
- Padding mode for ridge detection
- Options: "reflect", "constant", "edge", "symmetric", "wrap"
constant_value (default: 0.0):
- Value used for constant padding mode
- Typical range: 0.0-1.0
TIP
Best practice: Set scale_start and scale_end to span the expected range of vessel widths in your image. Use scale_step=2 for efficiency, or 1 for maximum precision.
Where to Use the Skill in a Pipeline
Filter Using Frangi is commonly used in the following pipelines:
- Retinal vessel segmentation - Detect blood vessels in retinal images
- Angiography analysis - Enhance vascular structures in medical scans
- Fingerprint enhancement - Enhance ridge structures
- Neuroimaging - Detect neural fibers and blood vessels
- Quality control - Detect cracks, scratches, or linear defects
A typical pipeline for retinal vessel analysis looks as follows:
# Example pipeline using Frangi (parameters omitted).
from telekinesis import pupil
from datatypes import datatypes, io
# 1. Load retinal image
image = io.load_image(filepath=...)
# 2. Preprocess and normalize
preprocessed = ...
# 3. Apply Frangi filter for vessel detection
vessels = pupil.filter_image_using_frangi(image=preprocessed, ...)
# 4. Threshold to create binary vessel map
binary_vessels = vessels > threshold
# 5. Clean up with morphology
cleaned = pupil.filter_image_using_morphological_open(image=binary_vessels ...)Related skills to build such a pipeline:
load_image: Load medical imagesfilter_image_morphological_open: Clean up vessel detection resultsfilter_image_using_hessian: Alternative vesselness measure
Alternative Skills
| Skill | vs. Filter Using Frangi |
|---|---|
| filter_image_using_hessian | Hessian vesselness is simpler. Use Frangi for more sophisticated vessel detection, Hessian for speed. |
| filter_image_using_sato | Sato is optimized for ridge detection. Use Frangi for vessels, Sato for general ridges. |
| filter_image_using_meijering | Meijering is optimized for neurites. Use Frangi for general vessels, Meijering for fine branching structures. |
When Not to Use the Skill
Do not use Filter Using Frangi when:
- You need simple edge detection (Use Sobel or Canny instead)
- You're detecting non-tubular structures (Use appropriate edge or blob detectors)
- You need very fast processing (Frangi is computationally expensive due to multi-scale analysis)
- Your structures are not vessel-like (Use general-purpose filters instead)
WARNING
Frangi filtering is computationally intensive due to multi-scale Hessian eigenvalue analysis. For large images, consider processing at reduced resolution or using a limited scale range.

