Image Analyst MKIIImage Processing Principles
HomeWorkflowImage Processing PrinciplesFunctions GlossaryPipelines GlossaryProtocolsQuick How ToSearch

website security

Differentiation in Time and Space: Savitzky-Golay Filters 

Physiological information is often encoded in rates. Differentiation in time tells that how fast is the change of the signal in each time point of the measurement, i.e. what is the slope of the intensity vs. time trace, performing the slope fitting at each time point. Differentiation in space tells that how steep are the edges of objects in the image.

Temporal differentiation of pixel values, which are discrete in time or in space is performed in the simplest case by subtracting the value occurred earlier from the value occurred later, and dividing it by the difference of the time point. Analogously, for differentiation along the x axis just replace time for space: considering that the x-axis increases from left to right the spatial derivative is calculated by subtracting the value on the left from the value on the right, and dividing it by the distance between them, which is 2.

In practice images are noisy, and differentiation amplifies noise. Therefore derivatives are calculated from more data points (pixel values) than strictly before and after the point of calculation.  The fundamental idea is to fit a different polynomial to the data surrounding each data point1. The smoothed points are computed by replacing each data point with the value of its fitted polynomial. Numerical derivatives come from computing the derivative of each fitted polynomial at each data point. In practice the polynomial coefficients can be computed with kernel filtering. Savitzky-Golay2,3,4 filters are kernels calculated to be mathematically identical to performing actual polynomial fitting within the window of the kernel. Image Analyst MKII calculates one or two-dimensional Savitzky-Golay filters for any given window size or polynomial order (obviously the size has to be greater then the order) and differentiation order. Savitzky-Golay filters with zero differentiation order perform polynomial smoothing.

When differentiating with Savitzky-Golay filtering, temporal derivatives are calculated by kernel filtering the intensity values observed over a given pixel during the time lapse and dividing these filtered values by the kernel filtered time axis. When spatial derivatives are calculated in pixels, the spatial coordinate increments by 1 by each pixel, so its differential is essentially one. Therefore spatial filtering of images with Savitzky-Golay filtering results true spatial gradients as intensity change / pixel.

Spatial differentiation using 2D Savitzky-Golay filtering calculates partial derivatives. The actual partial derivative calculated is described by the order as follows:0: smoothing; 1:dx, 2:dy, 3:dx2, 4:dxy, 5:dy2

One-dimensional Savitzky-Golay kernel examples:

With=3, 1st derivative, 1nd polynomial order

-0.5 0. 0.5

With=5, 1st derivative, 2nd polynomial order

-0.2 -0.1 0. 0.1 0.2

With=7, 1st derivative, 2nd polynomial order

-0.107 -0.071 -0.036 0. 0.036 0.071 0.107

With=15, 1st derivative, 2nd polynomial order

-0.025 -0.021 -0.018 -0.014 -0.011 -0.007 -0.004 0. 0.004 0.007 0.011 0.014 0.018 0.021 0.025

Two-dimensional Savitzky-Golay kernel examples (use 3rd order):

With=5, 0th derivative (smooth, "order"=0), 3nd polynomial order

-0.074 0.011 0.04 0.011 -0.074
0.011 0.097 0.126 0.097 0.011
0.04 0.126 0.154 0.126 0.04
0.011 0.097 0.126 0.097 0.011
-0.074 0.011 0.04 0.011 -0.074

With=5, 1th derivative along x axis ("order"=1), 3nd polynomial order

0.074 -0.105 0. 0.105 -0.074
-0.012 -0.148 0. 0.148 0.012
-0.04 -0.162 0. 0.162 0.04
-0.012 -0.148 0. 0.148 0.012
0.074 -0.105 0. 0.105 -0.074

With=5, 1th derivative along y axis ("order"=2), 3nd polynomial order

0.074 -0.012 -0.04 -0.012 0.074
-0.105 -0.148 -0.162 -0.148 -0.105
0. 0. 0. 0. 0.
0.105 0.148 0.162 0.148 0.105
-0.074 0.012 0.04 0.012 -0.074

Differentiation in Image Analyst MKII:

  • Filters/FTemporal Savitzky-Golay filter
  • Filters/F2D Savitzky-Golay filter


  1. Savitzky-Golay Filters for 2D Images, John Krumm Microsoft Research Microsoft Corporation
  2. Wikipedia: Savitzky–Golay smoothing filter
  3. Savitzky, A. Golay, M.J.E. (1964). "Smoothing and Differentiation of Data by Simplified Least Squares Procedures". Analytical Chemistry 36 (8): 1627–1639
  4. Press, WH., and S. Teukolsky. 1990. Savitzky-Golay Smoothing Filters. Computers in Physics 4:669