When performing measurements in digitized images, the pixel pitch does not necessarily limit the attainable accuracy. Proper sampling of a bandlimited continuous-domain image preserves all information present in the image prior to digitization. It is therefore (theoretically) possible to obtain measurements from the digitized image that are identical to measurements made in the continuous domain. Such measurements are sampling invariant, since they are independent of the chosen sampling grid. It is impossible to attain strict sampling invariance for filters in mathematical morphology due to their nonlinearity, but it is possible to approximate sampling invariance with arbitrary accuracy at the expense of additional computational cost. In this paper, we study morphological filters with line segments as structuring elements. We present a comparison of three known and three new methods to implement these filters. The method that yields a good compromise between accuracy and computational cost employs a (subpixel) skew to the image, followed by filtering along the grid axes using a discrete line segment, followed by an inverse skew. The staircase approximations to line segments under random orientations can be modeled by skewing a horizontal or vertical line segment. Rather than skewing the binary line segment we skew the image data, which substantially reduces quantization error. We proceed to determine the optimal number of orientations to use when measuring the length of line segments with unknown orientation.