pygorpho.strel

Structuring elements for mathematical morhology

pygorpho.strel.flat_ball_approx(radius, type=1)[source]

Returns approximation to flat ball using line segments.

The approximation is constructed according to [J19] and allows for constant time morphology operations.

Parameters:
  • r – Integer radius of flat ball.
  • type – Whether to constrain the zonohedral approximation inside or outside the sphere. Must either INSIDE, BEST, or OUTSIDE from constants.
Returns:

Tuple with step vectors and line lengths which parameterizes the line segments.

Return type:

(numpy.array, numpy.array)

Example

import numpy as np
import pygorpho as pg
# Dilation with ball approximation of radius 25
vol = np.zeros((100,100,100))
vol[50, 50, 50] = 1
lineSteps, lineLens = pg.strel.flat_ball_approx(25)
res = pg.flat.linear_dilate(vol, lineSteps, lineLens)

References

[J19]P. M. Jensen et al., “Zonohedral Approximation of Spherical Structuring Element for Volumetric Morphology,” Scandinavian Conference on Image Analysis (pp. 128-139). Springer. 2019.