Morphological Gradients

Include <mln/morpho/gradient.hpp>

Image{I}
image_concrete_t<I> gradient(I f, StructuringElement se)
Image{I}
image_concrete_t<I> external_gradient(I f, StructuringElement se)
Image{I}
image_concrete_t<I> internal_gradient(I f, StructuringElement se)

Compute the morphological gradients. Morphological gradients are operators enhancing variations of pixel intensity in a neighborhood determined by a structuring element. Three combinations are currently used:

  1. arithmetic difference between the dilation and the erosion; this is basic morphological gradient, also called Beucher gradient.

    \(\rho_B = \delta_B - \varepsilon_B\)

  2. arithmetic difference between the dilation and the original image; also called external gradient:

    \(\rho_B^{+} = \delta_B - \mathrm{id}\)

  3. arithmetic difference between the original image and its erosion; also called the internal_gradient:

    \(\rho_B^{-} = \mathrm{id} - \varepsilon_B\)

If input is not integral, the marginal ordering is considered and the 𝑙₂ of the vector difference is returned:

\(\rho_B = \left| \delta_B - \varepsilon_B \right|\)

Parameters:
  • f – Input image 𝑓

  • se – Elementary structuring element.

Returns:

An image whose type is deduced from the input image.

Precondition:

Exception:

N/A

Example 1 : Gradient by a square on a gray-level image

#include <mln/morpho/gradient.hpp>
#include <mln/core/se/rect2d.hpp>

// Define a square SE of size 7x7
auto input = ...;
auto rect = mln::se::rect2d(7,7);
auto grad1 = mln::morpho::gradient(input, rect);
auto grad2 = mln::morpho::internal_gradient(input, rect);
auto grad3 = mln::morpho::external_gradient(input, rect);
../_images/lena_gray.jpg
../_images/morpho_gradient_1.png

Beucher (thick) gradient

../_images/morpho_int_gradient_1.png

Internal gradient

../_images/morpho_ext_gradient_1.png

External Gradient