# Nonlinear filter

In signal processing, a nonlinear filter is a filter whose output is not a linear function of its input. That is, if the filter outputs signals R and S for two input signals r and s separately, but does not always output αR + βS when the input is a linear combination αr + βs.
Both continuous-domain and discrete-domain filters may be nonlinear. A simple example of the former would be an electrical device whose output voltage R(t) at any moment is the square of the input voltage r(t); or which is the input clipped to a fixed range [a,b], namely R(t) = max(a, min(b, r(t))). An important example of the latter is the running-median filter, such that every output sample R$_i$ is the median of the last three input samples r$_i$, r$_{i−1}$, r$_{i−2}$. Like linear filters, nonlinear filters may be shift invariant or not.
Non-linear filters have many applications, especially in the removal of certain types of noise that are not additive. For example, the median filter is widely used to remove spike noise — that affects only a small percentage of the samples, possibly by very large amounts. Indeed, all radio receivers use non-linear filters to convert kilo- to gigahertz signals to the audio frequency range; and all digital signal processing depends on non-linear filters (analog-to-digital converters) to transform analog signals to binary numbers.
However, nonlinear filters are considerably harder to use and design than linear ones, because the most powerful mathematical tools of signal analysis (such as the impulse response and the frequency response) cannot be used on them. Thus, for example, linear filters are often used to remove noise and distortion that was created by nonlinear processes, simply because the proper non-linear filter would be too hard to design and construct.
From the foregoing, we can know that the nonlinear filters have quite different behavior compared to linear filters. The most important characteristic is that, for nonlinear filters, the filter output or response of the filter does not obey the principles outlined earlier, particularly scaling and shift invariance. Furthermore, a nonlinear filter can produce results that vary in a non-intuitive manner.

## Linear system

Several principles define a linear system. The basic definition of linearity is that the output must be a linear function of the inputs, that is
    $\alpha y_{1}(t)+\beta y_{2}(t)=H\left\{\alpha x_{1}(t)+\beta x_{2}(t)\right\}$
for any scalar values $\alpha \,$ and $\beta \,$. This is a fundamental property of linear system design, and is known as superposition. So, a system is said to be nonlinear if this equation is not valid. That is to say, when the system is linear, the superposition principle can be applied. This important fact is the reason that the techniques of linear-system analysis have been so well developed.

## Applications
### Noise removal

Signals often get corrupted during transmission or processing; and a frequent goal in filter design is the restoration of the original signal, a process commonly called "noise removal". The simplest type of corruption is additive noise, when the desired signal S gets added with an unwanted signal N that has no known connection with S. If the noise N has a simple statistical description, such as Gaussian noise, then a Kalman filter will reduce N and restore S to the extent allowed by Shannon's theorem. In particular, if S and N do not overlap in the frequency domain, they can be completely separated by linear bandpass filters.
For almost any other form of noise, on the other hand, some sort of non-linear filter will be needed for maximum signal recovery. For multiplicative noise (that gets multiplied by the signal, instead of added to it), for example, it may suffice to convert the input to a logarithmic scale, apply a linear filter, and then convert the result to linear scale. In this example, the first and third steps are not linear.
Non-linear filters may also be useful when certain "nonlinear" features of the signal are more important than the overall information contents. In digital image processing, for example, one may wish to preserve the sharpness of silhouette edges of objects in photographs, or the connectivity of lines in scanned drawings. A linear noise-removal filter will usually blur those features; a non-linear filter may give more satisfactory results (even if the blurry image may be more "correct" in the information-theoretic sense).
Many nonlinear noise-removal filters operate in the time domain. They typically examine the input digital signal within a finite window surrounding each sample, and use some statistical inference model (implicitly or explicitly) to estimate the most likely value for the original signal at that point. The design of such filters is known as the filtering problem for a stochastic process in estimation theory and control theory.
Examples of nonlinear filters include:
* phase-locked loops
* detectors
* mixers
* median filters
* ranklets
Nonlinear filter also occupy a decisive position in the image processing functions. In a typical pipeline for real-time image processing, it is common to have many nonlinear filter included to form, shape, detect, and manipulate image information. Furthermore, each of these filter types can be parameterized to work one way under certain circumstances and another way under a different set of circumstance using adaptive filter rule generation. The goals vary from noise removal to feature abstraction. Filtering image data is a standard process used in almost all image processing systems. Nonlinear filters are the most utilized forms of filter construction. For example, if an image contains a low amount of noise but with relatively high magnitude, then a median filter may be more appropriate.

### Kushner–Stratonovich filtering

The context here is the formulation of the nonlinear filtering problem seen through the lens of the theory of stochastic processes. In this context, both the random signal and the noisy partial observations are described by continuous time stochastic processes. The unobserved random signal to be estimated is modeled through a non-linear Ito stochastic differential equation and the observation function is a continuous time non-linear transformation of the unobserved signal, an observation perturbed by continuous time observation noise.
Given the nonlinear nature of the dynamics, familiar frequency domain concepts that can be applied to linear filters are not viable, and a theory based on the state space representation is formulated. The complete information on the nonlinear filter at a given time is the probability law of the unobserved signal at that time conditional on the history of observations up to that time. This law may have a density, and the infinite dimensional equation for the density of this law takes the form of a stochastic partial differential equation (SPDE). The problem of optimal nonlinear filtering in this context was solved in the late 1950s and early 1960s by Ruslan L. Stratonovich and Harold J. Kushner. The optimal filter SPDE is called Kushner-Stratonovich equation. In 1969, Moshe Zakai introduced a simplified dynamics for the unnormalized conditional law of the filter known as Zakai equation. It has been proved by Mireille Chaleyat-Maurel and Dominique Michel that the solution is infinite dimensional in general, and as such requires finite dimensional approximations. These may be heuristics-based such as the extended Kalman filter or the assumed density filters described by Peter S. Maybeck or the projection filters introduced by Damiano Brigo, Bernard Hanzon and François Le Gland, some sub-families of which are shown to coincide with the assumed density filters. Particle filters are another option, related to sequential Monte Carlo methods.

### Energy transfer filters

Energy transfer filters are a class of nonlinear dynamic filters that can be used to move energy in a designed manner. Energy can be moved to higher or lower frequency bands, spread over a designed range, or focused. Many energy transfer filter designs are possible, and these provide extra degrees of freedom in filter design that are just not possible using linear designs.

## Types of Non-linear Filters
### Min Filter

A min filter also known as erosion in morphological image processing, is a spatial domain filter used for image processing. It replaces each pixel in the image with the minimum value of its neighboring pixels.
The size and shape of the neighborhood are defined by a structuring element, typically a square or circular mask.
The transformation replaces the central pixel with the darkest one in the running window.
For example, if you have text that is lightly printed, the minimum filter makes letters thicker.

### Max Filter

A max filter, also known as dilation in morphological image processing, is another spatial domain filter used for image processing.
It replaces each pixel in the image with the maximum value of its neighboring pixels, again defined by a structuring element.
The maximum and minimum filters are shift-invariant. Whereas the minimum filter replaces the central pixel with the darkest one in the running window, the maximum filter replaces it with the lightest one.
For example, if you have a text string drawn with a thick pen, you can make the sign skinnier.