DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# FiniteDifference

A linear gradient filter

## SYNOPSIS

`#include "dip_linear.h"`

dip_Error dip_FiniteDifference ( in, out, boundary, processDim, filter )

## DATA TYPES

binary, integer, float, complex

## FUNCTION

The FiniteDifference filter implements several basic one dimensional FIR convolution filters. The dimension in which the operation is to be performed is specified by `processDim`. The operation itself is selected with `filter`. The (1 0 -1)/2, (1 -1 0) & (0 1 -1) are difference filters that approximate a first order derivative, the (1 -2 1) filter approximates a second order derivative operation. The triangular (1 2 1)/4 filter is a local smoothing filter.

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `in` | Input image
`dip_Image` | `out` | Output image
`dip_BoundaryArray` | `boundary` | Boundary conditions
`dip_int` | `processDim` | ProcessDim
`dipf_FiniteDifference` | `filter` | Filter selection

The `dipf_FiniteDifference` enumeration consists of the following flags:

Name | Description
`DIP_FINITE_DIFFERENCE_M101` | out[ii] = (in[ii+1] - in[ii-1])/2
`DIP_FINITE_DIFFERENCE_0M11` | out[ii] = in[ii+1] - in[ii]
`DIP_FINITE_DIFFERENCE_M110` | out[ii] = in[ii] - in[ii-1]
`DIP_FINITE_DIFFERENCE_1M21` | out[ii] = in[ii-1] - 2*in[ii] + in[ii+1]
`DIP_FINITE_DIFFERENCE_121` | out[ii] = (in[ii-1] + 2*in[ii] + in[ii+1])/4

## SEE ALSO

General information about convolution

`FiniteDifferenceEx`, `SobelGradient`, `Uniform`, `Gauss`, `SeparableConvolution`, `Convolve1d`, `Derivative`