---
title: "DerivativeFilter"
language: "en"
type: "Symbol"
summary: "DerivativeFilter[data, {n1, n2, ...}] computes the ni\\[Null]^th derivative of data at level i. DerivativeFilter[data, {n1, n2, ...}, \\[Sigma]] computes the derivative at a Gaussian scale of standard deviation \\[Sigma]. DerivativeFilter[data, {der1, der2, ...}, ...] computes several derivatives der1, der2, ...."
keywords: 
- derivative
- calculus
- interpolation
- B-spline
- N-jet
- jet of derivatives
- derivative jet
- image derivative
- Hessian
- gradient
canonical_url: "https://reference.wolfram.com/language/ref/DerivativeFilter.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Image Filtering & Neighborhood Processing"
    link: "https://reference.wolfram.com/language/guide/ImageFilteringAndNeighborhoodProcessing.en.md"
  - 
    title: "Linear and Nonlinear Filters"
    link: "https://reference.wolfram.com/language/guide/LinearAndNonlinearFilters.en.md"
  - 
    title: "Video Computation: Update History"
    link: "https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md"
  - 
    title: "Signal Filtering & Filter Design"
    link: "https://reference.wolfram.com/language/guide/SignalFilteringAndFilterDesign.en.md"
related_functions: 
  - 
    title: "GaussianFilter"
    link: "https://reference.wolfram.com/language/ref/GaussianFilter.en.md"
  - 
    title: "Derivative"
    link: "https://reference.wolfram.com/language/ref/Derivative.en.md"
  - 
    title: "RidgeFilter"
    link: "https://reference.wolfram.com/language/ref/RidgeFilter.en.md"
  - 
    title: "DifferentiatorFilter"
    link: "https://reference.wolfram.com/language/ref/DifferentiatorFilter.en.md"
---
# DerivativeFilter

DerivativeFilter[data, {n1, n2, …}] computes the ni$$^{\text{th}}$$ derivative of data at level i.

DerivativeFilter[data, {n1, n2, …}, σ] computes the derivative at a Gaussian scale of standard deviation σ.

DerivativeFilter[data, {der1, der2, …}, …] computes several derivatives der1, der2, ….

## Details and Options

* ``DerivativeFilter`` is a linear filter that computes the derivatives of data based on a spline interpolation model. Regularization with a Gaussian kernel of standard deviation ``σ`` (defaults to 0) can be used to reduce susceptibility to noise.

[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                                    |

* ``DerivativeFilter`` operates separately on each level of ``data``.

* ``DerivativeFilter[image, …]`` uses the array coordinate system, where the first coordinate runs from the top to the bottom of ``image``, and the second coordinate increases from left to right.

* ``DerivativeFilter`` gives a result with the same dimensions as ``data``.

* ``DerivativeFilter`` can take the following options:

|                     |           |                             |
| ------------------- | --------- | --------------------------- |
| InterpolationOrder  | Automatic | interpolation order up to 9 |
| Padding             | "Fixed"   | padding method              |

* With ``Padding -> {pad1, pad2, …}``, different padding schemes can be used for every dimension of ``data``.

* The derivative order has to be smaller than the specified interpolation order.

## Examples (29)

### Basic Examples (3)

A horizontal derivative of an image:

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

Out[1]= [image]
```

---

A regularized horizontal derivative of an image:

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

Out[1]= [image]
```

---

Derivative of a numeric list:

```wl
In[1]:=
data = PixelValue[[image], {All, 60}];
der = DerivativeFilter[data, {1}];

In[2]:= ListLinePlot[{data, der}, PlotRange -> All]

Out[2]= [image]
```

### Scope (14)

#### Data (6)

First-order derivatives of a 2D array:

```wl
In[1]:= DerivativeFilter[BoxMatrix[1, 5], {1, 1}]//Chop//MatrixForm

Out[1]//MatrixForm=
(⁠|                  |                  |   |                  |                  |
| ---------------- | ---------------- | - | ---------------- | ---------------- |
| 0.4175368675726  | 0.3802439787472  | 0 | -0.3802439787472 | -0.4175368675726 |
 ... | 0                | 0                | 0 | 0                | 0                |
| -0.3802439787472 | -0.3462819564031 | 0 | 0.3462819564031  | 0.3802439787472  |
| -0.4175368675726 | -0.3802439787472 | 0 | 0.3802439787472  | 0.4175368675726  |⁠)
```

---

Obtain the first derivative of a ``TimeSeries`` object:

```wl
In[1]:=
ts = TemporalData[TimeSeries, {CompressedData["«590»"], {{0, 91, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 11.2];
filtered = DerivativeFilter[ts, {1}];
ListLinePlot[{ts, filtered}, PlotLegends -> {"original", "filtered"}]

Out[1]= [image]
```

---

Filter an ``Audio`` signal:

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

Out[1]= [image]

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

Out[2]= [image]
```

---

Vertical derivative of a color image:

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

Out[1]= [image]
```

---

Filter video frames:

```wl
In[1]:= DerivativeFilter[Video["ExampleData/fish.mp4"], {1, 0}]

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

---

Vertical derivative of a 3D image:

```wl
In[1]:= DerivativeFilter[[image], {1, 0, 0}]

Out[1]= [image]
```

#### Parameters (8)

Zeroth derivative of a list:

```wl
In[1]:= DerivativeFilter[{1, 2, -1, 0, 1, 2}, {0}]

Out[1]= {1, 2, -1, 0, 1, 2}
```

---

First, second and third derivatives of a step sequence:

```wl
In[1]:= step = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};ListLinePlot[DerivativeFilter[step, {{1}, {2}, {3}}], PlotRange -> All, Axes -> {True, False}, Ticks -> False, PlotLegends -> {1, 2, 3}]

Out[1]= [image]
```

---

Vertical derivative of an image:

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

Out[1]= [image]
```

Horizontal derivative:

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

Out[2]= [image]
```

---

Second-order derivative in both dimensions:

```wl
In[1]:= 10DerivativeFilter[[image], {2, 2}]

Out[1]= [image]
```

---

Compute several derivatives of an image:

```wl
In[1]:= ImageAdjust /@ DerivativeFilter[[image], {{1, 0}, {0, 1}, {0, 2}}]

Out[1]= [image]
```

---

Vertical derivative of a 3D image:

```wl
In[1]:=
i = [image];
DerivativeFilter[i, {1, 0, 0}]

Out[1]= [image]
```

Horizontal derivatives only:

```wl
In[2]:= DerivativeFilter[i, {0, 1, 1}]

Out[2]= [image]
```

---

Regularize the derivative using Gaussian smoothing:

```wl
In[1]:=
filtered = DerivativeFilter[TemporalData[TimeSeries, {CompressedData["«1192»"], {{0, 1., 0.01}}, 1, {"Continuous", 1}, {"Continuous", 1}, 1, 
  {ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 10.1], {1}, #]& /@ {0, 3};
ListLinePlot[filtered, PlotRange -> All, PlotLegends -> {"σ=0 (default)", "σ=3"}]

Out[1]= [image]
```

---

Horizontal derivative at different Gaussian scales:

```wl
In[1]:= ImageAdjust@DerivativeFilter[[image], {0, 1}, #]& /@ {0, 5, 10}

Out[1]= [image]
```

### Options (3)

#### InterpolationOrder (1)

Filtering an array using different ``InterpolationOrder`` values:

```wl
In[1]:=
Chop@MatrixForm@DerivativeFilter[ArrayPad[{1}, 5], {1}, 
InterpolationOrder -> #]& /@ {2, 3}

Out[1]=
{(⁠|                     |
| ------------------- |
| 0.0005947071198958  |
| -0.003466207108880  |
| 0.02020253553339    |
| -0.11774900609144   |
| 0.6862915010152     |
| 0                   |
| -0.6862915010152    |
| 0.11774900609144    |
| -0. ... 0  |
| -0.015464328428615  |
| 0.057713659400522   |
| -0.21539030917347   |
| 0.8038475772934     |
| 0                   |
| -0.8038475772934    |
| 0.21539030917347    |
| -0.057713659400522  |
| 0.015464328428615   |
| -0.0041436543139370 |⁠)}
```

#### Padding (2)

Derivative filtering using different padding schemes:

```wl
In[1]:=
v = {1, 2, 3, 2, 2, 1, 2, 1, 0, 0, 0};
pad = {"Fixed", "Periodic", "Reflected"};
ListLinePlot[DerivativeFilter[v, {1}, Padding -> #]& /@ pad, PlotLegends -> pad, PlotRange -> All]

Out[1]= [image]
```

---

First derivatives of a grayscale image using different padding schemes:

```wl
In[1]:= ImageAdjust[DerivativeFilter[[image], {1, 1}, 3, Padding -> #]]& /@ {"Fixed", "Periodic", 0.2}

Out[1]= [image]
```

Use different padding schemes in each spatial direction:

```wl
In[2]:= ImageAdjust[DerivativeFilter[[image], {1, 1}, 3, Padding -> {"Fixed", "Periodic"}]]

Out[2]= [image]
```

### Applications (5)

Compute the image gradient:

```wl
In[1]:=
{Ly, Lx} = DerivativeFilter[[image], {{1, 0}, {0, 1}}];
Sqrt[Lx^2 + Ly^2]//ImageAdjust

Out[1]= [image]
```

---

Compute the Laplacian of an image at scale ``σ = 6`` :

```wl
In[1]:=
{Lxx, Lyy} = DerivativeFilter[[image], {{2, 0}, {0, 2}}, 6];
Lxx + Lyy//ColorNegate//ImageAdjust

Out[1]= [image]
```

---

Ridge detection at scale ``σ = 2`` :

```wl
In[1]:=
σ = 2;
{Lxx, Lxy, Lyy} = DerivativeFilter[[image], {{0, 2}, {1, 1}, {2, 0}}, σ];
	
(σ^3 / 2/2)(Sqrt[(Lxx - Lyy)^2 + 4Lxy^2] - Lxx - Lyy)//ImageAdjust

Out[1]= [image]
```

---

T-junction filter:

```wl
In[1]:=
tJunctionFilter[img_, σ_ : 1] := 
	Module[
	{data = ImageData[img], Lx, Ly, Lxx, Lxy, Lyy, Lxxx, Lxxy, Lxyy, Lyyy}, 
	{Lx, Ly} = DerivativeFilter[data, {{0, 1}, {1, 0}}, σ];
	{Lxx, Lxy, Lyy} = DerivativeFilter[data, {{0, 2}, {1, 1}, {2, 0}}, σ];
	{Lxxx, Lxxy, Lxyy, Lyyy} = DerivativeFilter[data, {{0, 3}, {1, 2}, {2, 1}, {3, 0}}, σ];
	Image[
	Chop[-Lx^5Lxyy + Ly^4(2Lxy^2 - Lxxy Ly + Lxx Lyy) + Lx Ly^3(6Lxx Lxy - Lxxx Ly + 2Lxyy Ly - 6Lxy Lyy) + Lx^3Ly(-6Lxx Lxy - Lxxx Ly + Lxyy Ly + 6Lxy Lyy) + Lx^4(2Lxy^2 + 2Lxxy Ly + Lxx Lyy - Ly Lyyy) + Lx^2Ly^2(3Lxx^2 - 8Lxy^2 + Lxxy Ly - 4Lxx Lyy + 3Lyy^2 - Ly Lyyy)]
	]
	];
tJunctionFilter[[image], 2]//ImageAdjust

Out[1]= [image]
```

---

 Get borders from a colored map:

```wl
In[1]:= Norm[DerivativeFilter[[image], {{1, 0}, {0, 1}}]]

Out[1]= [image]
```

### Properties & Relations (4)

For larger values of $\sigma$, the results of ``GaussianFilter`` and ``DerivativeFilter`` converge:

```wl
In[1]:=
data = {0, 0, 1, 2, 1, 0, 0, 0, 0, 1, 2, 5, -1, 0, 2, 1};
σ = 0.5;
ListLinePlot[
	{DerivativeFilter[data, {1}, σ], GaussianFilter[data, σ{3, 1}, {1}]}, 
	PlotRange -> All
	]

Out[1]= [image]

In[2]:=
σ = 1;
ListLinePlot[
	{DerivativeFilter[data, {1}, σ], GaussianFilter[data, σ{3, 1}, {1}]}, 
	PlotRange -> All
	]

Out[2]= [image]

In[3]:=
σ = 1.5;
ListLinePlot[
	{DerivativeFilter[data, {1}, σ], GaussianFilter[data, σ{3, 1}, {1}]}, 
	PlotRange -> All
	]

Out[3]= [image]
```

---

``DerivativeFilter`` and the corresponding derivatives of a spline interpolation return the same values:

```wl
In[1]:= data = {0, 0, 0, 0, 0, 0, 0, 0, 0.7, 1, 1, 1, 1, 1, 1, 1, 1};f = ListInterpolation[data, Method -> "Spline", InterpolationOrder -> 3];f'[9]

Out[1]= 0.633975

In[2]:= DerivativeFilter[data, {1}, InterpolationOrder -> 3][[9]]

Out[2]= 0.633975
```

Plot the result of the filter on top of the derivative of the interpolating function:

```wl
In[3]:=
Plot[
	Evaluate[Derivative[1][f][x]], 
	{x, 1, Length[data]}, 
	PlotRange -> All, 
	Epilog -> {Red, PointSize[0.025], MapIndexed[Point[{First[#2], #1}]&, DerivativeFilter[data, {1}, InterpolationOrder -> 3]]}
	]

Out[3]= [image]
```

---

Derivative filtering of a binary image gives a grayscale image of a real type:

```wl
In[1]:= d = Image[DiskMatrix[10, 81], "Bit"];ImageType[DerivativeFilter[d, {1, 1}]]

Out[1]= "Real32"
```

---

``DerivativeFilter`` 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};
DerivativeFilter[list1 + list2, {1}] == DerivativeFilter[list1, {1}] + DerivativeFilter[list2, {1}]

Out[1]= True
```

## See Also

* [`GaussianFilter`](https://reference.wolfram.com/language/ref/GaussianFilter.en.md)
* [`Derivative`](https://reference.wolfram.com/language/ref/Derivative.en.md)
* [`RidgeFilter`](https://reference.wolfram.com/language/ref/RidgeFilter.en.md)
* [`DifferentiatorFilter`](https://reference.wolfram.com/language/ref/DifferentiatorFilter.en.md)

## Related Guides

* [Image Filtering & Neighborhood Processing](https://reference.wolfram.com/language/guide/ImageFilteringAndNeighborhoodProcessing.en.md)
* [Linear and Nonlinear Filters](https://reference.wolfram.com/language/guide/LinearAndNonlinearFilters.en.md)
* [Video Computation: Update History](https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md)
* [Signal Filtering & Filter Design](https://reference.wolfram.com/language/guide/SignalFilteringAndFilterDesign.en.md)

## History

* [Introduced in 2010 (8.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn80.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)