Skip to content

shock_filterShockFilterShockFiltershock_filtershock_filterπŸ”—

Short descriptionπŸ”—

shock_filterShockFilterShockFiltershock_filtershock_filter β€” Apply a shock filter to an image.

SignatureπŸ”—

shock_filter( image Image, out image SharpenedImage, real Theta, integer Iterations, string Mode, real Sigma )void ShockFilter( const HObject& Image, HObject* SharpenedImage, const HTuple& Theta, const HTuple& Iterations, const HTuple& Mode, const HTuple& Sigma )static void HOperatorSet.ShockFilter( HObject image, out HObject sharpenedImage, HTuple theta, HTuple iterations, HTuple mode, HTuple sigma )def shock_filter( image: HObject, theta: float, iterations: int, mode: str, sigma: float ) -> HObject

Herror shock_filter( const Hobject Image, Hobject* SharpenedImage, double Theta, const Hlong Iterations, const char* Mode, double Sigma )

Herror T_shock_filter( const Hobject Image, Hobject* SharpenedImage, const Htuple Theta, const Htuple Iterations, const Htuple Mode, const Htuple Sigma )

HImage HImage::ShockFilter( double Theta, Hlong Iterations, const HString& Mode, double Sigma ) const

HImage HImage::ShockFilter( double Theta, Hlong Iterations, const char* Mode, double Sigma ) const

HImage HImage::ShockFilter( double Theta, Hlong Iterations, const wchar_t* Mode, double Sigma ) const (Windows only)

HImage HImage.ShockFilter( double theta, int iterations, string mode, double sigma )

DescriptionπŸ”—

The operator shock_filterShockFilter applies a shock filter to the input image Imageimageimage to sharpen the edges contained in it. The principle of the shock filter is based on the transport of the gray values of the image towards an edge from both sides through dilation and erosion and satisfies the differential equation

\[\begin{eqnarray*} u_{t} = s \, |\nabla u| \end{eqnarray*}\]

on the function \(u\) defined by the gray values in Imageimageimage at a time \(t_{0} = 0\). The discretized equation is solved in Iterationsiterationsiterations time steps of length Thetathetatheta, so that the output image SharpenedImagesharpenedImagesharpened_image contains the gray value function at the time \(\textrm{Iterations} \cdot \textrm{Theta}\).

The decision between dilation and erosion is made using the sign function \(s\) with values {-1,0,+1} on a conventional edge detector. The detector of Canny

\[\begin{eqnarray*} s = -sgn\left( D^2 u(\frac{\nabla u}{|\nabla u|},\frac{\nabla u}{|\nabla u|}) \right) \end{eqnarray*}\]

is available with \(\textrm{Mode}='\textit{canny}'\) and the detector of Marr/Hildreth (the Laplace operator)

\[\begin{eqnarray*} s = -sgn(\Delta u) \end{eqnarray*}\]

can be selected by \(\textrm{Mode}='\textit{laplace}'\).

To make the edge detection more robust, in particular on noisy images, it can be performed on a smoothed image matrix. This is done by giving the standard deviation of a Gaussian kernel for convolution with the image matrix in the parameter Sigmasigmasigma.

AttentionπŸ”—

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

ParametersπŸ”—

Imageimageimage (input_object) (multichannel-)image(-array) β†’ object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Input image.

SharpenedImagesharpenedImagesharpened_image (output_object) image(-array) β†’ object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject * (byte / uint2 / real)

Output image.

Thetathetatheta (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Time step.

Default: 0.50.5
Suggested values: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.70.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7
Restriction: 0 < Theta <= 0.7

Iterationsiterationsiterations (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of iterations.

Default: 1010
Suggested values: 1, 3, 10, 1001, 3, 10, 100
Restriction: Iterations >= 1

Modemodemode (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of edge detector.

Default: 'canny'"canny"
List of values: 'canny', 'laplace'"canny", "laplace"

Sigmasigmasigma (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Smoothing of edge detector.

Default: 1.01.0
Suggested values: 0.0, 0.5, 1.0, 2.0, 5.00.0, 0.5, 1.0, 2.0, 5.0
Restriction: Theta >= 0

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 in Image Processingβ€™β€˜; Applied Mathematical Sciences 147; Springer, New York; 2002.

ModuleπŸ”—

Foundation