# Shock Filtering

As a first post to this blog, I will be referring to my Shock Filter implementation, which I believe is a great image processing tool to both get idea on PDEs and to come up with a practically working algorithm.

Quoting J. Weickert,
Shock filters are based in the idea to apply locally either dilation or erosion process, depending on whether the pixel belongs to the influence zone of a maximum or a minimum. They create a sharp shock between two influence zones and produce piece-wise constant segmentation.

Principle of shock filtering is applying dilation and erosion operations in order to satisfy the differential equation: $u_t=s|\nabla u|$ on the function $u$ defined by the gray values in the image. The decision between dilation and erosion is made using the signum function based on Laplace operator. Applying such a procedure produces a sharp discontinuity called shock at the borderline between two influence zones. The resulting equation reads Because Laplacian is a second derivative operator, using it alone will not be noise prone. For this reason, in order to make the edge detector more robust, $u_t$ is smoothed at each iteration by a Gaussian kernel. The rest is simply solving the mentioned PDE in an iterative fashion. The resulting effect is basically enhancement/sharpening of the input image. Below is a sample from Shock Filtering:

Entire source code can be found here

### References

F. Guichard, J. Morel; “A Note on Two Classical Shock Filters and Their Asymptotics”; Michael Kerckhove (Ed.): Scale-Space
and Morphology in Computer Vision, LNCS 2106, pp. 75-84; Springer, New York; 2001.
G. Aubert, P. Kornprobst; “Mathematical Problems inImage Processing”; Applied Mathematical Sciences 147; Springer, New
York; 2002.
J. Weickert Coherence-enhancing shock filters; In B. Michaelis, G. Krell (Eds.): Pattern Recognition. Lecture Notes in Computer
Science, Vol. 2781, Springer, Berlin, 1-8, 2003.