Function File: mmgradm (img)
Function File: mmgradm (img, se_dil)
Function File: mmgradm (img, se_dil, se_ero)

Perform morphological gradient.

The matrix img must be numeric whose gradients is calculated, while se_dil and se_ero are the structuring elements for the dilation and erosion respectively. They can be a:

  • strel object;
  • array of strel objects as returned by ‘@strel/getsequence’;
  • matrix of 0’s and 1’s.

The se_dil and se_ero default to the elementary cross, i.e.:

[ 0 1 0
  1 1 1
  0 1 0];

The basic morphological gradient corresponds to a matrix erosion subtracted to its dilation, which is equivalent to:

imdilate (img, se_dil) - imerode (img, se_ero)

To perform the half-gradients by erosion or dilation, or the internal or external gradients, simply pass an empty matrix as structuring element:

mmgradm (img, [], se_ero) # half-gradient by erosion or internal gradient
mmgradm (img, se_dil, []) # half-gradient by dilation or external gradient

See also: imerode, imdilate, imopen, imclose, imtophat, imbothat.

Package: image