Morphological filter
#include "dip_morphology.h"
dip_Error DirectedPathOpening ( grey, mask, out, param, closing, constrained )
binary, integer, float
Theoretically, the path opening can be written as the supremum of all the openings with each of the possible linear structuring elements of composed of a set number of pixels in the general orientation of param. The param parameter is interpreted as follows: length is set to max(param). direction is set to round(param/length). direction now contains only values 0, -1 or 1. A 90 degree cone is defined around the given direction, and this cone gives the neighbourhood connectivity. The structuring element is formed by length pixels connected according to this neighbourhood connectivity. For example, in 2D, if param is [10,0], the structuring element will be formed by 10 pixels connected either diagonally or horizontally. It will extend across exactly 10 horizontal pixels, but can vary in shape to adapt to local image content.
If closing is DIP_TRUE, the path closing will be computed instead of the opening.
If constrained is DIP_TRUE, the algorithm is modified as follows: Only one consecutive step is allowed in a direction other than the exact direction specified. For example, following the [10,0] example above, a diagonal step must be followed by at least one horizontal step. This avoids zig-zag lines, especially if the main direction is diagonal. It also reduces the maximal angle that a straight line can deviate from the chosen direction. The unconstrained algorithm will keep lines rotated by up to 45 degrees; the constrained algorithm limits this to 22.5 degrees.
The algorithm uses a boundary condition such that any line connected to the border is considered infinite in length. To constrain the lines to the image domain, set a two pixel border around the image to the minimum value, e.g. 0 (for the opening), or the maximum value, e.g. 255 (for the closing).
Data type | Name | Description |
dip_Image | grey | Grey-value input image |
dip_Image | mask | Mask image for ROI processing |
dip_Image | out | Output image |
dip_FloatArray | param | Size of structuring element |
dip_Boolean | closing | DIP_FALSE for path opening, DIP_TRUE for path closing |
dip_Boolean | constrained | DIP_TRUE for constrained paths, DIP_FALSE for the original path opening algorithm |
H. Talbot and B. Appleton, Efficient complete and incomplete path openings and closings, Image and Vision Computing 25:416-425, 2007.
C.L. Luengo Hendriks, Constrained and dimensionality-independent path openings, IEEE Transactions on Image Processing 19(6):1587-1595, 2010.