Filter Image Using Gabor
SUMMARY
Filter Image Using Gabor applies Gabor filter for texture analysis and feature detection.
Gabor filters are useful for detecting oriented features and textures at specific scales and orientations. These filters combine a Gaussian envelope with a sinusoidal wave, making them excellent for texture segmentation, pattern recognition, and feature extraction. They're particularly effective in applications like fingerprint analysis, fabric inspection, and biomedical image analysis.
Use this Skill when you want to detect oriented textures and features at specific scales and orientations.
The Skill
from telekinesis import pupil
filtered_image = pupil.filter_image_using_gabor(
image=image,
kernel_size=21,
standard_deviation=5.0,
orientation=0.0,
wavelength=10.0,
aspect_ratio=0.5,
phase_offset=0.0,
)Example
Input Image

Original grayscale image with textures
Filtered Image

Filtered image with kernel_size=21, wavelength=10.0, orientation=0.0 - specific texture features highlighted
The Code
from telekinesis import pupil
from datatypes import io
import pathlib
from loguru import logger
DATA_DIR = pathlib.Path("path/to/telekinesis-data")
# Load image
filepath = str(DATA_DIR / "images" / "finger_print.jpg")
image = io.load_image(filepath=filepath, as_gray=True)
logger.success(f"Loaded image from {filepath}")
# Apply Gabor filter for texture analysis and feature detection
filtered_image = pupil.filter_image_using_gabor(
image=image,
kernel_size=5,
standard_deviation=5.0,
orientation=90.0,
wavelength=5.0,
aspect_ratio=0.5,
phase_offset=90.0,
output_format="8bit",
)
# Access results
filtered_image_np = filtered_image.to_numpy()
logger.success("Applied Gabor filter. Filtered output image shape: {}", filtered_image_np.shape)The Explanation of the Code
The code begins by importing the necessary modules: pupil for image processing operations, io for data handling, pathlib for path management, and loguru for logging.
from telekinesis import pupil
from datatypes import io
import pathlib
from loguru import loggerNext, an image is loaded from a .jpg file using the io.load_image function. The image is loaded in grayscale mode using as_gray=True, which is appropriate for Gabor filtering that operates on single-channel intensity images.
DATA_DIR = pathlib.Path("path/to/telekinesis-data")
# Load image
filepath = str(DATA_DIR / "images" / "finger_print.jpg")
image = io.load_image(filepath=filepath, as_gray=True)The main operation uses the filter_image_using_gabor Skill from the pupil module. This Skill applies a Gabor filter for texture analysis and feature detection at specific scales and orientations. The parameters can be tuned to control kernel size, orientation, wavelength, and aspect ratio depending on the characteristics of the input image.
filtered_image = pupil.filter_image_using_gabor(
image=image,
kernel_size=5,
standard_deviation=5.0,
orientation=90.0,
wavelength=5.0,
aspect_ratio=0.5,
phase_offset=90.0,
output_format="8bit",
)Finally, the filtered image is converted to a NumPy array using to_numpy() for further processing, visualization, or downstream tasks.
filtered_image_np = filtered_image.to_numpy()
logger.success(f"Output image shape: {filtered_image_np.shape}")This operation is particularly useful in robotics and vision pipelines for texture analysis, pattern recognition, feature extraction, and fingerprint analysis, where detecting oriented textures at specific scales is required.
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_gaborHow to Tune the Parameters
The filter_image_using_gabor Skill has 6 parameters:
kernel_size (default: 19):
- The size of the Gabor kernel. Must be odd.
- Units: Pixels
- Increase to capture larger features
- Decrease for finer textures and faster processing
- Typical range: 5–51 (min: 5, max: 51)
- Use 5–15 for fine textures, 15–31 for medium, 31–51 for coarse textures
standard_deviation (default: 3.0):
- The standard deviation of the Gaussian envelope
- Units: Pixels
- Increase to create a wider filter
- Decrease for more localized response
- Typical range: 1.0–20.0 (min: 1.0, max: 20.0)
orientation (default: 0.0):
- The orientation of the filter in degrees
- Units: Degrees (0° horizontal, 90° vertical)
- Typical range: 0.0–180.0 (min: 0.0, max: 180.0)
- Use multiple orientations for complete texture analysis
wavelength (default: 6.0):
- The wavelength of the sinusoidal component
- Units: Pixels
- Increase to detect coarser features; Decrease to detect finer features
- Typical range: 2.0–50.0 (min: 2.0, max: 50.0)
aspect_ratio (default: 0.5):
- The aspect ratio of the filter (width/height)
- 1.0 is circular, <1.0 is elongated
- Typical range: 0.1–1.0 (min: 0.1, max: 1.0)
phase_offset (default: 90.0):
- The phase offset of the sinusoidal component in degrees
- Units: Degrees
- Typical range: 0.0–360.0 (min: 0.0, max: 360.0)
TIP
Best practice: For comprehensive texture analysis, apply Gabor filters at multiple orientations (e.g., 0°, 45°, 90°, 135°) and multiple scales (different wavelengths) to capture all texture features.
Where to Use the Skill in a Pipeline
Filter Using Gabor is commonly used in the following pipelines:
- Texture segmentation - Separate regions based on texture
- Fingerprint recognition - Detect ridge orientations
- Fabric inspection - Identify weave patterns and defects
- Biomedical imaging - Analyze tissue textures
- Face recognition - Extract texture features for identification
Related skills to build such a pipeline:
filter_image_using_gaussian_blur: Pre-smooth for noise reductionfilter_image_morphological_close: Post-process segmentation results
Alternative Skills
| Skill | vs. Filter Using Gabor |
|---|---|
| filter_image_using_sobel | Sobel detects edges, Gabor detects oriented textures. Use Sobel for simple edges, Gabor for texture analysis. |
| filter_image_using_gaussian_blur | Gaussian smooths, Gabor detects. Use Gaussian for preprocessing, Gabor for feature extraction. |
When Not to Use the Skill
Do not use Filter Using Gabor when:
- You only need simple edge detection (Use Sobel or Canny instead)
- You don't have oriented textures (Gabor is overkill for random textures)
- You need very fast processing (Gabor is computationally expensive)
- You're working with non-textured images (Use simpler edge detectors)

