HOME

TheInfoList



OR:

Image derivatives can be computed by using small convolution filters of size 2 × 2 or 3 × 3, such as the
Laplacian In mathematics, the Laplace operator or Laplacian is a differential operator given by the divergence of the gradient of a scalar function on Euclidean space. It is usually denoted by the symbols \nabla\cdot\nabla, \nabla^2 (where \nabla is the ...
, Sobel, Roberts and Prewitt operators. However, a larger mask will generally give a better approximation of the derivative and examples of such filters are Gaussian derivatives and Gabor filters. Sometimes high frequency noise needs to be removed and this can be incorporated in the filter so that the Gaussian kernel will act as a band pass filter. The use of Gabor filters in image processing has been motivated by some of its similarities to the perception in the human visual system. The pixel value is computed as a
convolution In mathematics (in particular, functional analysis), convolution is a mathematical operation on two functions ( and ) that produces a third function (f*g) that expresses how the shape of one is modified by the other. The term ''convolution'' ...
: p'_u=\mathbf \ast G where \mathbf is the derivative kernel and G is the pixel values in a region of the image and \ast is the operator that performs the
convolution In mathematics (in particular, functional analysis), convolution is a mathematical operation on two functions ( and ) that produces a third function (f*g) that expresses how the shape of one is modified by the other. The term ''convolution'' ...
.


Sobel derivatives

The derivative kernels, known as the
Sobel operator The Sobel operator, sometimes called the Sobel–Feldman operator or Sobel filter, is used in image processing and computer vision, particularly within edge detection algorithms where it creates an image emphasising edges. It is named after I ...
are defined as follows, for the u and v directions respectively: : p'_u = \begin +1 & +2 & +1 \\ 0 & 0 & 0 \\ -1 & -2 & -1 \end * \mathbf \quad \mbox \quad p'_v= \begin +1 & 0 & -1 \\ +2 & 0 & -2 \\ +1 & 0 & -1 \end * \mathbf where * here denotes the 2-dimensional
convolution In mathematics (in particular, functional analysis), convolution is a mathematical operation on two functions ( and ) that produces a third function (f*g) that expresses how the shape of one is modified by the other. The term ''convolution'' ...
operation. This operator is separable and can be decomposed as the products of an interpolation and a differentiation kernel, so that, p'_v, for an example can be written as : \begin +1 & 0 & -1 \\ +2 & 0 & -2 \\ +1 & 0 & -1 \end = \begin 1\\ 2\\ 1 \end \begin +1 & 0 & -1 \end


Farid and Simoncelli derivatives

Farid and Simoncelli propose to use a pair of kernels, one for interpolation and another for differentiation (compare to Sobel above). These kernels, of fixed sizes 5 x 5 and 7 x 7, are optimized so that the Fourier transform approximates their correct derivative relationship. In
Matlab MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
code the so called 5-tap filter is k = .030320 0.249724 0.439911 0.249724 0.030320 d = .104550 0.292315 0.000000 -0.292315 -0.104550 d2 = .232905 0.002668 -0.471147 0.002668 0.232905 And the 7-tap filter is k = 0.004711 0.069321 0.245410 0.361117 0.245410 0.069321 0.004711 d = 0.018708 0.125376 0.193091 0.000000 -0.193091 -0.125376 -0.018708 d2 = 0.055336 0.137778 -0.056554 -0.273118 -0.056554 0.137778 0.055336 As an example the first order derivatives can be computed in the following using
Matlab MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
in order to perform the
convolution In mathematics (in particular, functional analysis), convolution is a mathematical operation on two functions ( and ) that produces a third function (f*g) that expresses how the shape of one is modified by the other. The term ''convolution'' ...
Iu = conv2(d, k, im, 'same'); % derivative vertically (wrt Y) Iv = conv2(k, d, im, 'same'); % derivative horizontally (wrt X) It is noted that Farid and Simoncelli have derived first derivative coefficients which are more accurate compared to the ones provided above. However, the latter are consistent with the second derivative interpolator and, therefore, are better to use if both the first and second derivatives are sought. In the opposite case, when only the first derivative is desired, the optimal first derivative coefficients should be employed; more details can be found in their paper.


Hast derivatives

Derivative filters based on arbitrary cubic splines was presented by Hast. He showed how both first and second order derivatives can be computed more correctly using cubic or trigonometric splines. Efficient derivative filters need to be of odd length so that the derivative is computed for the central pixel. However, any cubic filter is fitted over 4 sample points, giving a centre that falls between pixels. This is solved by a double filtering approach giving filters of size 7 x 7. The idea is to first filter by interpolation so that the interpolated value between pixels are obtained, whereafter the procedure is repeated using a derivative filters, where the centre value now falls on pixel centres. This can easily be proved by the associative law for convolution : p'_u=\mathbf \ast (\mathbf \ast G) = (\mathbf \ast \mathbf) \ast G Therefore the convolution kernel for computing the derivative \mathbf using an interpolating kernel \mathbf and a derivative kernel \mathbf becomes : \mathbf=\mathbf \ast \mathbf Also keep in mind that convolution is commutative, so that the order of the two kernels does not matter and it is also possible to insert a second order derivative as well as a first order derivative kernel. These kernels are derived from the fact that any spline surface can be fitted over a square pixel region, compare to Bezier surfaces. Hast proves that such a surface can be performed as a separable convolution : p(u,v)=\mathbf^T MGM^T \mathbf = M^T \mathbf \otimes \mathbf^T M \ast G where M is the spline basis matrix, \mathbf and \mathbf are vectors containing the variables u and v, such as : \mathbf= ^3, u^2, u,1T : \mathbf= ^3, v^2, v,1T The convolution kernels can now be set to : \mathbf=\mathbf^T M = (M^T \mathbf)^T :\mathbf=\frac M = \left(M^T \frac \right)^T : \mathbf=\fracM = \left(M^T \frac \right)^T The first order derivatives at the central pixel are hence computed as : D_u=\fracM \ast \mathbf^T M G M^T \mathbf\ast M^T \mathbf= \mathbf \ast \mathbf \otimes (\mathbf \ast \mathbf)^T \ast G and : D_v=\mathbf^T M \ast \mathbf^T M G M^T \mathbf\ast M^T \frac= \mathbf \ast\mathbf \otimes (\mathbf \ast \mathbf)^T \ast G Likewise, with the second order derivative kernels are : D^2_u=\fracM \ast \mathbf^T M G M^T \mathbf\ast M^T \mathbf= \mathbf \ast \mathbf \otimes (\mathbf \ast \mathbf)^T \ast G and : D^2_v=\mathbf^T M \ast \mathbf^T M G M^T \mathbf\ast M^T \frac =\mathbf \ast \mathbf \otimes (\mathbf \ast \mathbf)^T \ast G The cubic spline filter is evaluated in its centre u=v=0.5 and therefore : \mathbf=\mathbf= 0.5)^3, (0.5)^2, 0.5, 1T= .125, 0.25, 0.5,1T Likewise the first order derivatives becomes : \frac=\frac= \cdot (0.5)^2, 2 \cdot (0.5), 1, 0T = .75, 1,1,0^T And in a similar manner the second order derivatives are : \frac=\frac= \cdot (0.5), 2, 0, 0T= ,2,0,0T Any cubic filter can be applied and used for computing the image derivates using the above equations, such as Bézier,
Hermite Charles Hermite () FRS FRSE MIAS (24 December 1822 – 14 January 1901) was a French mathematician who did research concerning number theory, quadratic forms, invariant theory, orthogonal polynomials, elliptic functions, and algebra. Her ...
or
B-spline In the mathematical subfield of numerical analysis, a B-spline or basis spline is a spline function that has minimal support with respect to a given degree, smoothness, and domain partition. Any spline function of given degree can be expresse ...
s. The example in below in
Matlab MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
use the Catmull-Rom spline to compute the derivatives M = ,-3,3,-1; -1,4,-5,2; 0,1,0,-1; 0,0,2,0* 0.5; u = .125;0.25;0.5;1 up = .75;1;1;0 d = up'*M; k = u'*M; Iu = conv2(conv(d,k), conv(k,k), im,'same'); % vertical derivative (wrt Y) Iv = conv2(conv(k,k), conv(d,k), im,'same'); % horizontal derivative (wrt X)


Other approaches

Steerable filters can be used for computing derivatives Moreover, Savitzky and Golay propose a least-squares polynomial smoothing approach, which could be used for computing derivatives and Luo et al discuss this approach in further detail. Scharr shows how to create derivative filters by minimizing the error in the Fourier domain and Jähne et alB. Jähne, P. Geissler, H. Haussecker (Eds.), Handbook of Computer Vision and Applications with Cdrom, 1st ed., Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 1999, pp. 125–151 (Chapter 6). discuss in more detail the principles of filter design, including derivative filters.


References

{{Reflist


External links


derivative5.m
Farid and Simoncelli: 5-Tap 1st and 2nd discrete derivatives.
derivative7.m
Farid and Simoncelli: 7-Tap 1st and 2nd discrete derivatives
kernel.m
Hast: 1st and 2nd discrete derivatives for Cubic splines, Catmull-Rom splines, Bezier splines, B-Splines and Trigonometric splines. Image processing Generalizations of the derivative