Path openings and closings are morphological operations with flexible line segments as structuring elements. These line segments have the ability to adapt to local image structures, and can be used to detect lines that are not perfectly straight. They also are a convenient and efficient alternative to straight line segments as structuring elements when the exact orientation of lines in the image is not known. These path operations are defined by an adjacency relation, which typically allows for lines that are approximately horizontal, vertical or diagonal. However, because this definition allows zig-zag lines, diagonal paths can be much shorter than the corresponding horizontal or vertical paths. This undoubtedly causes problems when attempting to use path operations for length measurements. This paper 1) introduces a dimensionality-independent implementation of the path opening and closing algorithm by Appleton and Talbot, 2) proposes a constraint on the path operations to improve their ability to perform length measurements, and 3) shows how to use path openings and closings in a granulometry to obtain the length distribution of elongated structures directly from a gray-value image, without a need for binarizing the image and identifying individual objects.