---
title: "GaborFilter"
language: "en"
type: "Symbol"
summary: "GaborFilter[data, r, k] filters data by convolving with a Gabor kernel of pixel radius r and wave vector k. GaborFilter[data, r, k, \\[Phi]] uses a Gabor kernel with phase shift \\[Phi]. GaborFilter[data, {r, \\[Sigma]}, ...] uses a Gabor kernel with radius r and standard deviation \\[Sigma]."
keywords: 
- image processing
- Gabor filter
- Gabor matrix
- Gabor structure
- Gabor transform
- Fourier
- filter
canonical_url: "https://reference.wolfram.com/language/ref/GaborFilter.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Image Filtering & Neighborhood Processing"
    link: "https://reference.wolfram.com/language/guide/ImageFilteringAndNeighborhoodProcessing.en.md"
  - 
    title: "Video Computation: Update History"
    link: "https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md"
related_functions: 
  - 
    title: "GaborMatrix"
    link: "https://reference.wolfram.com/language/ref/GaborMatrix.en.md"
  - 
    title: "GaussianFilter"
    link: "https://reference.wolfram.com/language/ref/GaussianFilter.en.md"
  - 
    title: "GradientFilter"
    link: "https://reference.wolfram.com/language/ref/GradientFilter.en.md"
  - 
    title: "LaplacianFilter"
    link: "https://reference.wolfram.com/language/ref/LaplacianFilter.en.md"
  - 
    title: "ImageConvolve"
    link: "https://reference.wolfram.com/language/ref/ImageConvolve.en.md"
  - 
    title: "ListConvolve"
    link: "https://reference.wolfram.com/language/ref/ListConvolve.en.md"
---
# GaborFilter

GaborFilter[data, r, k] filters data by convolving with a Gabor kernel of pixel radius r and wave vector k.

GaborFilter[data, r, k, ϕ] uses a Gabor kernel with phase shift ϕ.

GaborFilter[data, {r, σ}, …] uses a Gabor kernel with radius r  and standard deviation σ.

## Details and Options

* ``GaborFilter`` is a linear, spatially directional and frequency-selective filter commonly used in image processing for texture analysis and segmentation. In the spatial domain, a 2D Gabor filter kernel is a Gaussian function modulated by a sinusoidal plane wave.

[image]

* The ``data`` can be any of the following:

|         |                                                   |
| ------- | ------------------------------------------------- |
| list    | arbitrary-rank numerical array                    |
| tseries | temporal data such as TimeSeries, TemporalData, … |
| image   | arbitrary Image or Image3D object                 |
| audio   | an Audio object                                   |
| video   | a Video object                                    |

* ``GaborFilter[data, r, k]`` is equivalent to ``GaborFilter[data, {r, r / 2}, k, 0]``.

* Either of the ``r`` or ``σ`` can be lists, specifying different values for different directions.

* ``GaborFilter[image, …]`` by default gives an image of a real type of the same dimensions as ``image``.

* The following options can be specified:

|                   |           |                                                               |
| ----------------- | --------- | ------------------------------------------------------------- |
| Padding           | "Fixed"   | padding method                                                |
| Standardized      | True      | whether to rescale the Gabor kernel to account for truncation |
| WorkingPrecision  | Automatic | the precision to use                                          |

* With a setting ``Padding -> None``, ``GaborFilter[data, …]`` normally gives a result smaller than ``data``.

---

## Examples (25)

### Basic Examples (3)

Filter an image:

```wl
In[1]:= GaborFilter[[image], 20, {.5, .5}]//ImageAdjust

Out[1]= [image]
```

---

Gabor filtering of a 3D image:

```wl
In[1]:= 10GaborFilter[[image], 5, {0, 0, 1}]

Out[1]= [image]
```

---

Apply a Gabor filter to a list of values:

```wl
In[1]:=
list = N@Table[Sin[ π t^2 + 2π], {t, 0, 5, (1/30)}];
ListLinePlot[{list, GaborFilter[ list, 20, {.5}]}]

Out[1]= [image]
```

### Scope (8)

#### Data (5)

Gabor filtering of a 2D array:

```wl
In[1]:=
mat = Array[KroneckerDelta, {20, 20}];
res = GaborFilter[mat, 10, {.5, -.5}];
ArrayPlot /@ {mat, res}

Out[1]= {[image], [image]}
```

---

Filter a ``TimeSeries`` object:

```wl
In[1]:=
ts = TemporalData[TimeSeries, {CompressedData["«1188»"], {{0, 1., 0.01}}, 1, {"Continuous", 1}, {"Continuous", 1}, 1, 
  {ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 10.1];

In[2]:= filtered = GaborFilter[ts, 10, {.1}]

Out[2]=
TemporalData[TimeSeries, {CompressedData["«1186»"], {{0, 1., 0.01}}, 1, {"Continuous", 1}, {"Continuous", 1}, 1, 
  {ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 14.3]

In[3]:= ListLinePlot[{ts, filtered}, PlotLegends -> {"original data", "filtered"}]

Out[3]= [image]
```

---

Filter an ``Audio`` signal:

```wl
In[1]:=
a = Import["ExampleData/rule30.wav"];
b = AudioNormalize[GaborFilter[a, 20, {1}]]

Out[1]= [image]

In[2]:= AudioPlot[{a, b}]

Out[2]= [image]
```

---

Filter a color image:

```wl
In[1]:= GaborFilter[[image], 20, {0.3, 0.3}]//ImageAdjust

Out[1]= [image]
```

---

Filter video frames:

```wl
In[1]:= GaborFilter[Video["ExampleData/fish.mp4"], 10, {0.3, 0.3}]

Out[1]= \!\(\*VideoBox["![Embedded Video Player](video://content-jh7uf)"]\)
```

#### Parameters (3)

Gabor filtering of a noisy signal using different kernel radii:

```wl
In[1]:=
ts = TemporalData[TimeSeries, {CompressedData["«1188»"], {{0, 1., 0.01}}, 1, {"Continuous", 1}, {"Continuous", 1}, 1, 
  {ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 10.1];

In[2]:=
filtered = GaborFilter[ts, #, {0}]& /@ {1, 3, 9};
ListLinePlot[filtered, PlotLegends -> {"r=1", "r=3", "r=9"}]

Out[2]= [image]
```

Use different standard deviations:

```wl
In[3]:=
filtered = GaborFilter[ts, {9, #}, {0}]& /@ {1, 5};
ListLinePlot[filtered, PlotLegends -> {"σ=1", "σ=5"}]

Out[3]= [image]
```

Use different wave vectors:

```wl
In[4]:=
filtered = Table[GaborFilter[ts, 3, {k}], {k, {0., π / 3., 2π / 3.}}];
ListLinePlot[filtered, PlotLegends -> {"k={0}", "k={π/3}", "k={2π/3}"}]

Out[4]= [image]
```

---

Gabor filtering in the vertical direction:

```wl
In[1]:= GaborFilter[[image], 6, {π / 3, 0}]//ImageAdjust

Out[1]= [image]
```

Filtering in the horizontal direction:

```wl
In[2]:= GaborFilter[[image], 6, {0, π / 3}]//ImageAdjust

Out[2]= [image]
```

Filtering in a diagonal direction:

```wl
In[3]:= GaborFilter[[image], 6, {π, π} / 4]//ImageAdjust

Out[3]= [image]
```

---

The cosine part of a Gabor filter is computed when $\phi =0$ :

```wl
In[1]:= GaborFilter[[image], 3, {1, 1}, 0]//ImageAdjust

Out[1]= [image]
```

The sine part of a Gabor filter is computed when $\phi =\pi /2$ :

```wl
In[2]:= GaborFilter[[image], 3, {1, 1}, π / 2]//ImageAdjust

Out[2]= [image]
```

### Options (6)

#### Padding (3)

Gabor filtering using different padding schemes:

```wl
In[1]:=
v = Table[SawtoothWave[(n/10)], {n, -10, 10}];
pad = {"Fixed", "Periodic", "Reversed"};

In[2]:= ListLinePlot[GaborFilter[v, 5, {0}, Padding -> #]& /@ pad, PlotRange -> All, PlotLegends -> pad]

Out[2]= [image]
```

---

Gabor filtering of a grayscale image using different padding schemes:

```wl
In[1]:= ImageAdjust[GaborFilter[[image], 20, {Pi, Pi} / 2, Padding -> #]]& /@ {"Fixed", "Periodic"}

Out[1]= [image]
```

---

``Padding -> None`` normally returns an image smaller than the input image:

```wl
In[1]:= GaborFilter[[image], 20, {0, 0}, Padding -> None]

Out[1]= [image]
```

#### WorkingPrecision (3)

``MachinePrecision`` is by default used with integer arrays:

```wl
In[1]:= GaborFilter[{3, 4, 4, 3}, 1, {1}]

Out[1]= {2.76378, 3.55077, 3.55077, 2.76378}
```

Perform exact computation instead:

```wl
In[2]:= GaborFilter[{3, 4, 4, 3}, 1, {1}, WorkingPrecision -> ∞]

Out[2]= {(3 Sqrt[(2/π)]/Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2)) + (7 Sqrt[(2/π)] Cos[1]/E^2 (Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2))), (4 Sqrt[(2/π)]/Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2)) + (7 Sqrt[(2/π)] Cos[1]/E^2 (Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2))), (4 Sqrt[(2/π)]/Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2)) + (7 Sqrt[(2/π)] Cos[1]/E^2 (Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2))), (3 Sqrt[(2/π)]/Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2)) + (7 Sqrt[(2/π)] Cos[1]/E^2 (Sqrt[(2/π)] + (2 Sqrt[(2/π)]/E^2)))}
```

---

With real arrays, by default the precision of the input is used:

```wl
In[1]:= GaborFilter[{1.0000000000000000000, 2.0000000000000000000, 3.0000000000000000000, 4.0000000000000000000}, 1, {1}]

Out[1]= {0.9596239410648790375, 1.804155949527571049, 2.706233924291356574, 3.550765932754048586}
```

Specify the precision to use:

```wl
In[2]:= GaborFilter[{1.0000000000000000000, 2.0000000000000000000, 3.0000000000000000000, 4.0000000000000000000}, 1, {1}, WorkingPrecision -> MachinePrecision]

Out[2]= {0.959624, 1.80416, 2.70623, 3.55077}
```

---

``WorkingPrecision`` is ignored when filtering images:

```wl
In[1]:= GaborFilter[[image], 2, {1, 1}, WorkingPrecision -> Infinity]

Out[1]= [image]
```

An image of a real type is always returned:

```wl
In[2]:= ImageType[%]

Out[2]= "Real32"
```

### Applications (3)

Gabor filtering of an image to detect vertical lines in an image:

```wl
In[1]:= GaborFilter[[image], {9, {3, 1}}, {0, 2}]//ImageAdjust

Out[1]= [image]
```

---

Detect edges in the specified direction in a noisy image:

```wl
In[1]:= GaborFilter[[image], 6, {1, 1} / 2, Pi / 2]//ImageAdjust

Out[1]= [image]
```

---

The magnitude of the Gabor filter is computed as the squared norm of the sine and cosine components:

```wl
In[1]:= gaborMagnitude[image_, r_, k_] := With[{data = ImageData[image]}, Image[GaborFilter[image, r, k, 0] ^ 2 + GaborFilter[image, r, k, Pi / 2] ^ 2]]
```

Extract regions with the dominant direction parallel to $-45 {}^{\circ}$ and $45 {}^{\circ}$ :

```wl
In[2]:=
i = [image];
λ = .5;r = 10;
{t1, t2} = Table[ImageAdjust[gaborMagnitude[i, r, λ k]], {k, {{1, -1}, {1, 1}}}]

Out[2]= [image]
```

Highlight two texture segments on the image:

```wl
In[3]:= ImageCompose[i, {ImageAdd@@MapThread[ImageMultiply[MorphologicalBinarize[#1], #2]&, {{t1, t2}, {Red, Green}}], .3}]

Out[3]= [image]
```

### Properties & Relations (5)

``GaborFilter`` is equivalent to a convolution with a ``GaborMatrix`` :

```wl
In[1]:=
i = [image];
g1 = GaborFilter[i, 10, .5{1, -1}]//ImageAdjust

Out[1]= [image]

In[2]:= g2 = ImageConvolve[i, GaborMatrix[10, .5{1, -1}]]//ImageAdjust

Out[2]= [image]

In[3]:= g1 === g2

Out[3]= True
```

---

Gabor filtering with a zero-valued wave vector is equivalent to Gaussian smoothing:

```wl
In[1]:= GaborFilter[{1, 1, 1, 1, 1, 0, 0, 3, 12, 1, 0, 0, 0, 0, 0}, 1, {0}] == GaussianFilter[{1, 1, 1, 1, 1, 0, 0, 3, 12, 1, 0, 0, 0, 0, 0}, 1, Method -> "Gaussian"]

Out[1]= True
```

---

Impulse response of a Gabor filter:

```wl
In[1]:=
h = GaborFilter[ArrayPad[{{1}}, 10], 10, .75{1, 1}];
ListPlot3D[h, Mesh -> False, PlotRange -> All]

Out[1]= [image]
```

Magnitude spectrum of the filter:

```wl
In[2]:= Plot3D[Evaluate[Abs@ListFourierSequenceTransform[h, {u, v}]], {u, 0, π}, {v, 0, π}, Mesh -> False, PlotRange -> All]

Out[2]= [image]
```

---

Gabor filtering of an image gives a real-valued image:

```wl
In[1]:= GaborFilter[[image], 5, {1, 1}]//ImageAdjust

Out[1]= [image]
```

---

``GaborFilter`` is a linear filter:

```wl
In[1]:=
list1 = {1, 1, 1, 1, 1, 0, 0, 3, 12, 1, 0, 0, 0, 0, 0};
list2 = {2, 2, 2, 2, 1, 5, 4, 6, 2, 2, 1, 1, 1, 1, 1};
GaborFilter[list1 + list2, 1, {1}] == GaborFilter[list1, 1, {1}] + GaborFilter[list2, 1, {1}]

Out[1]= True
```

## See Also

* [`GaborMatrix`](https://reference.wolfram.com/language/ref/GaborMatrix.en.md)
* [`GaussianFilter`](https://reference.wolfram.com/language/ref/GaussianFilter.en.md)
* [`GradientFilter`](https://reference.wolfram.com/language/ref/GradientFilter.en.md)
* [`LaplacianFilter`](https://reference.wolfram.com/language/ref/LaplacianFilter.en.md)
* [`ImageConvolve`](https://reference.wolfram.com/language/ref/ImageConvolve.en.md)
* [`ListConvolve`](https://reference.wolfram.com/language/ref/ListConvolve.en.md)

## Related Guides

* [Image Filtering & Neighborhood Processing](https://reference.wolfram.com/language/guide/ImageFilteringAndNeighborhoodProcessing.en.md)
* [Video Computation: Update History](https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md)

## History

* [Introduced in 2012 (9.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn90.en.md) \| [Updated in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) ▪ [2016 (11.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn110.en.md) ▪ [2025 (14.3)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn143.en.md)