---
title: "DifferentiatorFilter"
language: "en"
type: "Symbol"
summary: "DifferentiatorFilter[data, \\[Omega]c] applies a differentiator filter with a cutoff frequency \\[Omega]c to an array of data. DifferentiatorFilter[data, \\[Omega]c, n] uses a filter kernel of length n. DifferentiatorFilter[data, \\[Omega]c, n, wfun] applies a smoothing window wfun to the filter kernel."
keywords: 
- differentiator filter
- image filter
- data filter
- sound filter
- sound derivative
- derivative
canonical_url: "https://reference.wolfram.com/language/ref/DifferentiatorFilter.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Linear and Nonlinear Filters"
    link: "https://reference.wolfram.com/language/guide/LinearAndNonlinearFilters.en.md"
  - 
    title: "Image Filtering & Neighborhood Processing"
    link: "https://reference.wolfram.com/language/guide/ImageFilteringAndNeighborhoodProcessing.en.md"
  - 
    title: "Signal Filtering & Filter Design"
    link: "https://reference.wolfram.com/language/guide/SignalFilteringAndFilterDesign.en.md"
  - 
    title: "Video Computation: Update History"
    link: "https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md"
related_functions: 
  - 
    title: "LowpassFilter"
    link: "https://reference.wolfram.com/language/ref/LowpassFilter.en.md"
  - 
    title: "HilbertFilter"
    link: "https://reference.wolfram.com/language/ref/HilbertFilter.en.md"
  - 
    title: "LeastSquaresFilterKernel"
    link: "https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.en.md"
  - 
    title: "ListConvolve"
    link: "https://reference.wolfram.com/language/ref/ListConvolve.en.md"
  - 
    title: "ImageConvolve"
    link: "https://reference.wolfram.com/language/ref/ImageConvolve.en.md"
  - 
    title: "DerivativeFilter"
    link: "https://reference.wolfram.com/language/ref/DerivativeFilter.en.md"
  - 
    title: "GaussianFilter"
    link: "https://reference.wolfram.com/language/ref/GaussianFilter.en.md"
---
# DifferentiatorFilter

DifferentiatorFilter[data, ωc] applies a differentiator filter with a cutoff frequency ωc to an array of data.

DifferentiatorFilter[data, ωc, n] uses a filter kernel of length n.

DifferentiatorFilter[data, ωc, n, wfun] applies a smoothing window wfun to the filter kernel.

## Details and Options

* ``DifferentiatorFilter`` is a finite impulse response (FIR) discrete-time filter that is commonly used to approximate the derivative of sampled data.

[image]

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

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

* When applied to images and multidimensional arrays, filtering is applied successively to each dimension, starting at level 1. ``DifferentiatorFilter[data, {ωc1, ωc2, …}]`` uses the frequency ``ωci`` for the ``i``$$^{\text{th}}$$ dimension.

* Filtering with cutoff frequency ``ωc`` reduces the susceptibility of the derivative to signal noise, with the amount of smoothing dependent on the value of the cutoff frequency ``ωc``.

* The cutoff frequency ``ωc`` should be between 0 and $\pi$. Smaller values of ``ωc`` result in greater smoothing.

* ``DifferentiatorFilter[data, ωc]`` uses a filter kernel length and smoothing window suitable for the cutoff frequency ``ωc`` and the input ``data``.

* Typical smoothing windows ``wfun`` include:

|     |     |
| --- | --- |
| BlackmanWindow | smoothing with a Blackman window |
| DirichletWindow | no smoothing |
| HammingWindow | smoothing with a Hamming window |
| {v1, v2, …} | use a window with values vi |
| f   | create a window by sampling f between $-1/2$ and $1/2$ |

* The following options can be given:

|             |           |                                   |
| ----------- | --------- | --------------------------------- |
| Padding     | "Fixed"   | the padding value to use          |
| SampleRate  | Automatic | sample rate assumed for the input |

* By default, ``SampleRate -> 1`` is assumed for images as well as data. For sampled ``sound`` objects with sample rate ``r``, ``SampleRate -> r`` is used.

* With ``SampleRate -> r``, the cutoff frequency ``ωc`` should be between 0 and ``r``×$\pi$.

---

## Examples (26)

### Basic Examples (2)

Differentiate a sampled cosine signal:

```wl
In[1]:=
dx = 0.1;
data = Table[Cos[2x], {x, 0, 2π, dx}];
ListLinePlot[{data, (1/ 2dx) DifferentiatorFilter[data, Pi, 20]}]

Out[1]= [image]
```

---

Differentiate an image:

```wl
In[1]:= DifferentiatorFilter[[image], Pi / 2]//ImageAdjust

Out[1]= [image]
```

### Scope (10)

#### Data (7)

Filter a 1D triangular sequence:

```wl
In[1]:=
data = BoxMatrix[5, {41}];
ListLinePlot[{data, DifferentiatorFilter[data, 1.]}, PlotRange -> All]

Out[1]= [image]
```

---

Filter a 2D pulse sequence:

```wl
In[1]:=
data = Table[UnitBox[(n/7), (m/7)], {n, -7, 7}, {m, -7, 7}];
ListPlot3D[data]

Out[1]= [image]

In[2]:= ListPlot3D[DifferentiatorFilter[data, 1.], PlotRange -> All]

Out[2]= [image]
```

---

Filter a ``TimeSeries`` :

```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];
filtered = DifferentiatorFilter[ts, Quantity[10, "Hertz"]];

In[2]:= ListLinePlot[{ts, 5filtered}, PlotLegends -> {"original", "filtered"}, PlotRange -> All]

Out[2]= [image]
```

---

Digital differentiation of a square wave audio signal:

```wl
In[1]:= a = AudioGenerator["Square"]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-gsfre)"]\)

In[2]:= DifferentiatorFilter[a, Quantity[15000, "Hertz"]]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-jxkl1)"]\)
```

---

Filter video frames:

```wl
In[1]:= DifferentiatorFilter[Video["ExampleData/fish.mp4"], 3]

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

---

Differentiation of a 3D image:

```wl
In[1]:= 200DifferentiatorFilter[[image], Pi]

Out[1]= [image]
```

---

Filter using exact precision:

```wl
In[1]:= DifferentiatorFilter[{0, 0, 0, 1, 1, 1, 0, 0, 0}, Pi, 4]

Out[1]= {0, 0, -(8/207 π), (631/207 π), -(8/207 π), (8/207 π), -(631/207 π), (8/207 π), 0}
```

#### Parameters (3)

With an audio signal, a numeric cutoff frequency is interpreted as radians per second:

```wl
In[1]:= a = \!\(\*AudioBox["![Embedded Audio Player](audio://content-iz4x8)"]\);

In[2]:= DifferentiatorFilter[a, 10000 2 Pi] === DifferentiatorFilter[a, Quantity[10000*2*Pi, "Radians"/"Seconds"]] === DifferentiatorFilter[a, Quantity[10000, "Hertz"]]

Out[2]= True
```

---

Differentiation of a unit step sequence using a filter of length 7:

```wl
In[1]:= DifferentiatorFilter[{0., 0., 0., 0., 1., 1., 1., 1.}, Pi, 6]

Out[1]= {0., 0., 0.00442866, -0.0525, 1.10973, -0.0525, 0.00442866, 1.5178830414797062`*^-16}
```

Use a different cutoff frequency:

```wl
In[2]:= DifferentiatorFilter[{0., 0., 0., 0., 1., 1., 1., 1.}, Pi / 2, 6]

Out[2]= {0., 0., 0.00916597, 0.144268, 0.320632, 0.144268, 0.00916597, 5.204170427930421`*^-17}
```

Use a specific window function:

```wl
In[3]:= DifferentiatorFilter[{0., 0., 0., 0., 1., 1., 1., 1.}, Pi, 6, BlackmanWindow]

Out[3]= {0., 0., 0., -0.0284032, 1.05287, -0.0284032, 6.522560269672795`*^-16, 6.522560269672795`*^-16}
```

Specify the window function as a numeric list:

```wl
In[4]:= DifferentiatorFilter[{0., 0., 0., 0., 1., 1., 1., 1.}, Pi, 6, {1, 1, 1, 1, 1, 1}]

Out[4]= {0., 0., 0.0509296, -0.0905415, 1.1827, -0.0905415, 0.0509296, 1.3877787807814457`*^-17}
```

---

Use different cutoff frequencies in each dimension:

```wl
In[1]:= DifferentiatorFilter[[image], {Pi / 3, Pi}, 20]//ImageAdjust

Out[1]= [image]
```

### Options (4)

#### Padding (2)

By default, ``"Fixed"`` padding is used:

```wl
In[1]:= DifferentiatorFilter[[image], Pi / 3, 21]//ImageAdjust

Out[1]= [image]
```

Use ``Padding -> None`` to eliminate potential image border artifacts:

```wl
In[2]:= DifferentiatorFilter[[image], Pi / 3, 21, Padding -> None]//ImageAdjust

Out[2]= [image]
```

---

Different padding methods result in different edge effects:

```wl
In[1]:=
ramp = Range[21] / 21. + RandomReal[.1, 21];
GraphicsRow@(ListLinePlot[{ramp, DifferentiatorFilter[ramp, Pi, 6, Padding -> #]}, ...]& /@ {"Fixed", "Periodic", 0})

Out[1]= [image]
```

#### SampleRate (2)

Use a half-band differentiating filter, assuming a normalized sample rate of 1:

```wl
In[1]:= DifferentiatorFilter[{0, 0, 0, 1, 1, 1, 0, 0, 0}, π / 2., 5]

Out[1]= {0., 0.0217391, 0.194734, 0.194734, 0., -0.194734, -0.194734, -0.0217391, 0.}
```

Assume a sample rate of 3:

```wl
In[2]:= DifferentiatorFilter[{0, 0, 0, 1, 1, 1, 0, 0, 0}, 3 π / 2., 5, SampleRate -> 3]

Out[2]= {0., 0.0217391, 0.194734, 0.194734, 0., -0.194734, -0.194734, -0.0217391, 0.}
```

---

Apply a half-band differentiator filter to audio sampled at a rate of ``Quantity[44100, "Hertz"]`` :

```wl
In[1]:=
a = AudioGenerator[Sin[11025 2 π  #^2]&];
sr = QuantityMagnitude@AudioSampleRate[a]

Out[1]= 44100

In[2]:= DifferentiatorFilter[a, sr π / 2., 21]//Periodogram

Out[2]= [image]
```

### Applications (2)

Use a derivative filter to highlight edges in an image:

```wl
In[1]:= DifferentiatorFilter[[image], Pi, 6]//ImageAdjust

Out[1]= [image]
```

---

Convert a triangle wave to a square wave:

```wl
In[1]:=
x = Table[TriangleWave[n / 32], {n, 0, 63}]//N;
y = DifferentiatorFilter[x, Pi, 6, Padding -> "Periodic"];

In[2]:= GraphicsRow[{ListPlot[x, Filling -> 0, ImageSize -> Small], ListPlot[y, Filling -> 0, ImageSize -> Small]}]

Out[2]= [image]
```

### Properties & Relations (7)

Create a differentiator filter using ``LeastSquaresFilterKernel`` and a Hamming window:

```wl
In[1]:=
n = 5;
ω = 1.5;
win = Array[HammingWindow, n, {-1 / 2, 1 / 2}];
ker = win LeastSquaresFilterKernel[{"Differentiator", ω}, n]

Out[1]= {0.0215281, 0.154205, 0, -0.154205, -0.0215281}

In[2]:= ListConvolve[ker, {0, 0, 0, 0, 1, 1, 1, 1}, Ceiling[n / 2], 0]

Out[2]= {0., 0., 0.0215281, 0.175734, 0.175734, 0.0215281, -0.0215281, -0.175734}
```

Compare with the result of ``DifferentiatorFilter`` :

```wl
In[3]:= DifferentiatorFilter[{0, 0, 0, 0, 1, 1, 1, 1}, ω, n, win, Padding -> 0]

Out[3]= {0., 0., 0.0215281, 0.175734, 0.175734, 0.0215281, -0.0215281, -0.175734}
```

---

Impulse response of an odd-length, full-band derivative filter of length 21:

```wl
In[1]:= h = DifferentiatorFilter[ArrayPad[{1.}, 10], Pi, 21]

Out[1]= {-0.00869565, 0.0121445, -0.0217681, 0.0393059, -0.0670675, 0.108696, -0.171138, 0.270605, -0.456406, 0.977656, 0., -0.977656, 0.456406, -0.270605, 0.171138, -0.108696, 0.0670675, -0.0393059, 0.0217681, -0.0121445, 0.00869565}

In[2]:= ListPlot[h, PlotRange -> All, Filling -> 0]

Out[2]= [image]
```

Magnitude spectrum of the filter:

```wl
In[3]:= Plot[Abs[ListFourierSequenceTransform[h, ω]], {ω, 0, π}]

Out[3]= [image]
```

---

Magnitude spectrum of an odd-length, full-band derivative filter with no smoothing window:

```wl
In[1]:= Plot[Evaluate@Abs[ListFourierSequenceTransform[DifferentiatorFilter[ArrayPad[{1.}, 10], Pi, 21, None], ω]], {ω, 0, π}]

Out[1]= [image]
```

---

Impulse response of an even-length derivative filter:

```wl
In[1]:= h = DifferentiatorFilter[ArrayPad[{1.}, 10], Pi, 20]

Out[1]= {0., -0.000306694, 0.000492079, -0.0010368, 0.00221336, -0.00453956, 0.00913553, -0.0188871, 0.0434262, -0.133687, 1.26531, -1.26531, 0.133687, -0.0434262, 0.0188871, -0.00913553, 0.00453956, -0.00221336, 0.0010368, -0.000492079, 0.000306694}

In[2]:= ListPlot[h, PlotRange -> All, Filling -> 0]

Out[2]= [image]
```

Magnitude spectrum of the filter:

```wl
In[3]:= Plot[Abs[ListFourierSequenceTransform[h, ω]], {ω, 0, π}, PlotRange -> All]

Out[3]= [image]
```

---

Magnitude spectrum of an even-length, full-band derivative filter with no smoothing window:

```wl
In[1]:= Plot[Evaluate@Abs[ListFourierSequenceTransform[DifferentiatorFilter[ArrayPad[{1.}, 10], Pi, 20, None], ω]], {ω, 0, π}]

Out[1]= [image]
```

---

Magnitude response of an odd-length differentiator filter for different filter lengths:

```wl
In[1]:=
Manipulate[
	ListLinePlot[Abs[Fourier[DifferentiatorFilter[ArrayPad[{1.}, 128], Pi, n], FourierParameters -> {1, -1}]][[ ;; 129]], ...], {{n, 21}, 3, 127, 2}]

Out[1]= DynamicModule[«8»]
```

---

Impulse response of a half-band, odd-length derivative filter:

```wl
In[1]:= h = DifferentiatorFilter[ArrayPad[{1.}, 10], Pi / 2, 21]

Out[1]= {0.00434783, 0.000429523, -0.010884, -0.00178735, 0.0335338, 0.00691978, -0.0855689, -0.0287121, 0.228203, 0.311198, 0., -0.311198, -0.228203, 0.0287121, 0.0855689, -0.00691978, -0.0335338, 0.00178735, 0.010884, -0.000429523, -0.00434783}

In[2]:= ListPlot[h, PlotRange -> All, Filling -> 0]

Out[2]= [image]
```

Magnitude spectrum of the filter:

```wl
In[3]:= Plot[Abs[ListFourierSequenceTransform[h, ω]], {ω, 0, π}]

Out[3]= [image]
```

### Possible Issues (1)

With ``Padding -> None``, the output will be shorter than the input:

```wl
In[1]:= DifferentiatorFilter[{0., 0., 0., 1., 1., 1.}, 1., Padding -> None]

Out[1]= {0.109492}
```

## See Also

* [`LowpassFilter`](https://reference.wolfram.com/language/ref/LowpassFilter.en.md)
* [`HilbertFilter`](https://reference.wolfram.com/language/ref/HilbertFilter.en.md)
* [`LeastSquaresFilterKernel`](https://reference.wolfram.com/language/ref/LeastSquaresFilterKernel.en.md)
* [`ListConvolve`](https://reference.wolfram.com/language/ref/ListConvolve.en.md)
* [`ImageConvolve`](https://reference.wolfram.com/language/ref/ImageConvolve.en.md)
* [`DerivativeFilter`](https://reference.wolfram.com/language/ref/DerivativeFilter.en.md)
* [`GaussianFilter`](https://reference.wolfram.com/language/ref/GaussianFilter.en.md)

## Related Guides

* [Linear and Nonlinear Filters](https://reference.wolfram.com/language/guide/LinearAndNonlinearFilters.en.md)
* [Image Filtering & Neighborhood Processing](https://reference.wolfram.com/language/guide/ImageFilteringAndNeighborhoodProcessing.en.md)
* [Signal Filtering & Filter Design](https://reference.wolfram.com/language/guide/SignalFilteringAndFilterDesign.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 2015 (10.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn102.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)