Skip to content

Filter Image Using Meijering

SUMMARY

Filter Image Using Meijering applies Meijering filter for neurite detection.

Meijering filter is optimized for detecting neurites and similar branching structures in biomedical images. This specialized filter is designed to enhance fine, branching neural processes and other delicate biological structures. It's particularly effective in neuronal imaging where detecting thin, branching processes is critical for morphological analysis and connectivity studies.

Use this Skill when you want to detect neurites and fine branching structures in biological images.

The Skill

python
from telekinesis import pupil

neurites = pupil.filter_image_using_meijering(
    image=image,
    scale_start=1,
    scale_end=10,
    scale_step=2,
    detect_black_ridges=True,
    border_type="reflect",
    constant_value=0.0,
)

API Reference

Example

Input Image

Input image

Original grayscale image with branching structures (normalized to 0-1 range)

Output Image

Output image

Enhanced image highlighting neurite structures

The Code

python
from telekinesis import pupil
from datatypes import io, datatypes

import pathlib
from loguru import logger

DATA_DIR = pathlib.Path("path/to/telekinesis-data")

# Load the grayscale image
filepath = str(DATA_DIR / "images" / "sidewalk_cracked.jpg")
image = io.load_image(filepath=filepath, as_gray=True)

# Apply Meijering filter
neurites = pupil.filter_image_using_meijering(
    image=image,
    scale_start=1,
    scale_end=6,
    scale_step=1,
    detect_black_ridges=True,
    border_type="reflect",
    constant_value=0.0,
)
logger.success(f"Applied Meijering filter with neurites shape as {neurites.to_numpy().shape}")

The Explanation of the Code

The Meijering filter is a specialized multi-scale filter designed to enhance fine, branching tubular structures, such as neurites in neuronal images. It builds on Hessian-based analysis but is tuned to better respond to thin, elongated structures that exhibit frequent branching and varying orientations.

The code begins by importing the required modules. These imports provide access to the Pupil SDK for image filtering, numerical utilities for preprocessing, and optional logging.

python
from telekinesis import pupil
from datatypes import io, datatypes

import pathlib
from loguru import logger

A data directory is defined, and the input image is loaded as a grayscale image. Meijering filtering operates on single-channel intensity images, as the vesselness response is derived from spatial derivatives rather than color information.

python
DATA_DIR = pathlib.Path("path/to/telekinesis-data")

# Load the grayscale image
filepath = str(DATA_DIR / "images" / "sidewalk_cracked.jpg")
image = io.load_image(filepath=filepath, as_gray=True)

Next, the parameters controlling the multi-scale Meijering analysis are configured. The Meijering filter is specifically designed for neurite detection in microscopy images, using a multi-scale approach to enhance thin, branching structures while suppressing background and noise.

scale_start, scale_end, and scale_step parameters define the range of scales over which neurite structures are analyzed. Smaller scales emphasize very thin branches and fine processes, while larger scales respond to thicker processes and junctions. The multi-scale analysis ensures that neurites of varying thickness are detected.
detect_black_ridges determines whether the filter looks for dark neurites on a bright background or the opposite. This matches the contrast polarity typical in fluorescence microscopy where neurites appear darker or brighter than the background.
border_type and constant_value parameters control how image borders are handled when the filter evaluates pixels near the edges of the image, where derivative calculations require pixels outside the image boundaries.

The Meijering filter is then applied using the filter_image_using_meijering Skill. The filter evaluates neurite-likeness at each scale and retains the strongest response per pixel across all scales.

python
neurites = pupil.filter_image_using_meijering(
    image=image,
    scale_start=1,
    scale_end=6,
    scale_step=1,
    detect_black_ridges=True,
    border_type="reflect",
    constant_value=0.0,
)
logger.success(f"Applied Meijering filter with neurites shape as {neurites.to_numpy().shape}")

The output is a neurite enhancement map, where higher values indicate a stronger likelihood that a pixel belongs to a thin, branching structure. 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:

bash
cd telekinesis-examples
python examples/pupil_examples.py --example filter_image_using_meijering

How to Tune the Parameters

The filter_image_using_meijering Skill has 6 parameters:

scale_start (default: 1):

  • The minimum scale (sigma) for structure detection
  • Typical range: 1-5
  • Determines the finest neurite width to detect

scale_end (default: 10):

  • The maximum scale (sigma) for structure detection
  • Typical range: 5-20
  • Determines the thickest neurite width to detect

scale_step (default: 2):

  • The step size between scales
  • Typical range: 1-5
  • Use 2 for efficiency, 1 for maximum precision

detect_black_ridges (default: True):

  • Whether to detect dark ridges instead of bright
  • Set True for dark neurites on bright background

border_type (default: "reflect"):

  • Padding mode
  • 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 to capture the finest neurites and scale_end to span cell bodies. Use scale_step=2 for good balance.

Where to Use the Skill in a Pipeline

Filter Using Meijering is commonly used in the following pipelines:

  • Neurite tracing - Detect and trace neuronal processes
  • Morphological analysis - Quantify neurite length and branching
  • Neural connectivity - Map neural network structures
  • Drug screening - Analyze neurite outgrowth in response to compounds
  • Developmental biology - Study neural development patterns

A typical pipeline for neurite tracing looks as follows:

python
# Example pipeline using Meijering (parameters omitted).

from telekinesis import pupil
from datatypes import io

# 1. Load neuronal image
image = io.load_image(filepath=...)

# 2. Preprocess
preprocessed = pupil.filter_image_using_gaussian_blur(image=image, ...)

# 3. Apply Meijering for neurite detection
neurites = pupil.filter_image_using_meijering(image=preprocessed, ...)

# 4. Threshold to binary
binary = neurites > threshold

# 5. Skeletonize for tracing
skeleton = pupil.transform_mask_using_blob_thinning(image=binary, ...)

Related skills to build such a pipeline:

  • load_image: Load microscopy images
  • filter_image_using_gaussian_blur: Pre-smooth
  • filter_mask_using_blob_thinning: Skeletonize for tracing
  • filter_image_using_frangi: Alternative for thicker structures

Alternative Skills

Skillvs. Filter Using Meijering
filter_image_using_frangiFrangi is for vessels. Use Meijering for fine neurites, Frangi for thicker tubular structures.
filter_image_using_satoSato is for general ridges. Use Meijering for branching neurites, Sato for non-branching ridges.
filter_image_using_hessianHessian is simpler. Use Meijering for neurite-specific detection.

When Not to Use the Skill

Do not use Filter Using Meijering when:

  • You're detecting thick vessels or non-branching structures (Use Frangi or Hessian instead)
  • You need simple edge detection (Use Sobel or Canny)
  • Structures are not neurite-like (Use appropriate filters)
  • You need very fast processing (Meijering is computationally expensive)

WARNING

Meijering filtering is specialized for neurites. For general tubular structures, consider using Frangi or Hessian filters instead.