Crossing-The-Line Segmentation as a Basis for Rsm and Rc Evaluation

Feature characterization of rough surfaces is of growing interest in terms of a function oriented description of technical surfaces. Feature characterization requires a segmentation of significant hills and dales of the measured profile. The segmentation can be done in several ways. One method is the so called crossing-the-line segmentation which will be part of ISO 16610 part 45 and ISO 21920 part 2. The crossing-the-line segmentation described in this publication represents an extension of the algorithm proposed by Scott (Scott P, 2006, Meas. Sci. Technol. 17, 559–564) and is based on new knowledge gathered over the last ten years. As an example, the feature parameters R S m and R c according to ISO 4287:1997 are evaluated.


Introduction
The characterization of profile surface texture with corresponding parameters is described in the standard ISO 4287:1997 [1]. The standard includes not only the well-known amplitude parameters Ra, Rq, Rz but also the mean width of all profile elements RSm based on the segmentation in individual profile features for a lateral characterization [1] (see [2,3] for an historical overview). However the current RSm parameter definition in ISO 4287:1997 has revealed some issues. First, the RSm parameter is defined as the mean width of profile elements, though it is intended to be a spacing parameter (RSm=roughness spacing mean). This does not affect the evaluation as long as there are no portions in the profile that are neither hill nor dale. However such zero elements can be part of real profiles and this issue has not yet been addressed in the current definition. Furthermore, current recommendations in ISO 4287:1997 regarding detection thresholds cause problems when handling several profiles, as will be shown in section 2.3. Finally the current description lacks further instructions or program flow charts for an unambiguous implementation. This leads to results of different measuring instruments and evaluation routines not being comparable. For example even the direction of evaluation can lead to different results in profile feature spacing, as later illustrated in section 3.1.
Feature characterization is a powerful tool in terms of a function oriented description of technical surfaces. The corresponding analysis methods have been researched extensively for areal surface texture evaluation (see [4] for an overview) and were included in the corresponding standardization in the meantime [5,6]. For areal feature characterization, the watershed transformation is commonly applied to segment hills and dales [5]. The method was extended towards an application in the GPS system amongst others by Wolf [7] and Scott [8]. Since the corresponding instructions have been published in the standard ISO 25178-2 in 2012 [5] they have also been developed further [9]. In the field of areal metrology, feature-based analysis is used for example for the characterization of additively manufactured surfaces [10].
It can be already predicted that feature-based evaluation methods will have a growing incidence in the future standardization: in the future profile standard ISO 21920 which is currently being developed by WG 16 of ISO TC 213 under participation of some of the authors, a paradigm shift will be included. Most of the relevant profile surface texture parameters will be defined with the aid of profile hills and profile dales rather than the spatial height values. This means, that Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. the feature-based analysis will be the default case in future profile surface texture evaluation. As a result, it is inevitable that the feature-based characterization of rough surfaces follows rigorously defined methods.
Feature characterization techniques require a segmentation of significant geometrical features. In the profile case, such geometrical features are e.g. hills and dales (peaks and valleys in ISO 4287:1997). Concerning the x-axis of a measured profile as a reference line for profile evaluation, hills are typically above the reference line and dales are typically below the reference line. In order to separate hills and dales the zero crossings of the profile with the reference line have to be calculated. This technique is called crossing-the-line segmentation and has been intensely discussed and developed in the WG 16 of ISO TC 213 during the last decade.
In this paper, we describe an unambiguous implementation of this type of segmentation, which will consequently also be included in the profile standard ISO 21920. We suggest a determination of profile elements based on the crossing-the-line segmentation in order to ensure a comparability of feature-based evaluations. The algorithm detects hills and dales with regard to distinct mathematical criteria, applies a vertical threshold to eliminate insignificant features, merges adjacent hills and dales and finally determines e.g. the parameter PSm, RSm, WSm based on all profile elements. The objective is the specification of an unambiguous implementation and to address the challenges of current implementations following ISO 4287:1997. The main aspects of the new algorithm can be summarized as follows: robust identification of zero crossings, definition of a zero element (points lying on the reference line) which can be assigned neither to a hill nor dale, two different vertical limits for hills and dales. The algorithm leads to an unambiguous parameter evaluation and is simple to implement. Besides a detailed analysis of the described profile features, a program flow chart and finally implementations both in Matlab and Python will be given to show the ease of use of the proposed algorithm.

Crossing-the-line segmentation of profile features
In this paper a profile feature is defined as a specific portion of a profile with a specific geometrical property. The task of the crossing-the-line segmentation is to separate different profile features with the aim to enable a feature based characterization in a next step. As an example, the number of features or the mean width of features are simple values for a feature based characterization. The first type of feature is called a profile hill. A profile hill is usually an outwardly directed (from material to surrounding medium) portion of the profile connecting two adjacent intersection points of the profile and the reference line (x-axis). The second type of feature is called a profile dale. Contrary to a profile hill, a profile dale is usually an inwardly directed (from surrounding medium to material) portion of the assessed profile connecting two adjacent intersection points of the assessed profile and the reference line. The third type of feature is called a zero element. A zero element is usually a continuous profile portion on the reference line. The reference line is usually defined by the corresponding ISO standard for a given type of profile, rather than being of arbitrary choice. For example the R-profile that is used for the calculation of Rparameters (like RSm) is derived by applying a l s low pass filter, subtracting the nominal shape and applying a l c high pass filter to eliminate waviness in the profile. The resulting R-profile according to ISO 4287-1997 therefore has a reference line equal to zero. Because of this, with no loss of generality the reference line is set to be equal to the zero line in this manuscript. However the following algorithm can be applied to any given profile with a corresponding reference line unequal zero by simply subtracting this reference line from the profile. In order to carry out the segmentation, the crossing-the-line algorithm is separated into three calculation steps: detection of profile features by zero crossing, application of a vertical limit criterion in order to delete insignificant profile features, merging of profile features of the same type.

Definitions
To simplify the implementation of the segmentation procedure two function calls are used. The first function is the modified signum function which calculates the sign of a real number Î  z depending on the positive real numbers Î +  u l , : The second function is the root function which calculates the intersection of the profile with the reference line by linear interpolation: as the coordinates of the profile whose linear connection intersects the reference line. If the intersection point lies outside the interval x x , , [ ] then the associated interval limit is used instead of the intersection point. Throughout the paper a discrete representation x z , k k ( ) of the continuous profile z x ( ) is used. It is assumed that the values x k are sorted in ascending order. The following variables are defined: n number of profile samples, x k position on the reference line (in ascending } , k h index of the profile value indicating a profile feature height, n PF total number of profile features,

Detection of profile features by zero crossing
The detection of profile features is based on zero crossings, i.e. the intersection of the profile with the reference line. For two adjacent profile samples, say z j−1 and z j , three cases have to be distinguished: -The connecting line of two adjacent profile samples intersect the reference line in such a way, that z j−1 lies below or on the reference line and z j lies above the reference line or z j−1 lies below the reference and z j lies above or on the reference line (figure 1(a))).
-The connecting line of two adjacent profile samples intersect the reference line in such a way, that z j−1 lies above or on the reference line and z j lies below the reference line or z j−1 lies above the reference line and z j lies below or on the reference line ( figure 1(b))).
-Two adjacent profile samples lie on the reference line ( figure 1(c))).
The three cases can be summarized mathematically as follows: a zero crossing is detected if In order to improve the robustness detecting zero crossings if numerical noise is present it is recommended to consider 'a region of doubt' for each profile sample around the reference line (see figure 2). The noise may cause a data point lie closely below the reference line which belong above and vice versa. The zone of doubt allows such a point to be a crossing point if its   and H l which are used for detecting the feature types hill and dale. The necessity for detection thresholds will be further discussed in section 2.3. The resulting procedure is given by the following rule: a zero crossing is detected if It is straight forward to decide which type of feature (hill, dale or zero element) is separated by each zero crossing. Index j−1 of a zero crossing indicates the end of a feature type and index j indicates the start of a new feature type. Per definition, the first profile feature begins at index j=1 and the last profile feature ends at j=n, with n the number of profile samples. The profile samples within each profile feature region are evaluated in the following manner: The previously described algorithm can be summarized in pseudo code: 2.3. Vertical limit criterion ISO 4287:1997 recommends the use of a vertical and a horizontal detection threshold to eliminate insignificant profile features and avoid oversegmentation. However, applying implementations that use the current definition of RSm on stochastic profiles shows a correlation between the choice of the horizontal threshold and the resulting RSm parameter as shown in figure 3. With an increasing value of the horizontal discrimination, also the value of RSm increases as the number and area of discarded profile elements increases.
Furthermore hills that are sufficiently above the reference line might not exist in every profile. Robust filtering of plateau-like surface profiles can lead to plateaus being exactly on the reference line, that cannot be detected with a vertical threshold unequal zero (see figure 4).
Therefore the use of horizontal discrimination is abandoned in favour of two separate vertical limits for dale detection H l and hill detection H .
u In doing this, the hill height discrimination limit H u and the upper noise threshold O H can both be set to zero to allow the detection of plateaus as pseudo-hills. The same can be done for H l and O D to detect flat dales on the reference line in certain profiles. Consider the k-th profile feature: k is lower than the vertical limit H l or lower than the lower zero crossing limit O . ).
An implementation of the vertical limit criterion is given by the subsequent pseudo code

Merging of profile features
After the insignificant profile features have been deleted, possibly adjacent features of the same type are present in the dataset. All adjacent profile features of the same type are merged to one feature. This is done since both the current ISO 4287:1997 and the future ISO 21920 require the combination of adjacent profile features of a different type to profile elements as later described in section 3. The new feature height is the maximal feature height of all merged elements and the left intersection point x l of the first merged profile feature and the right intersection point x r of the last merged profile feature bound the region of the new feature. Here is the entire process step as pseudo code:

Crossing-the-line segmentation and the profile parameters Rsm and Rc
2D-roughness parameters as Ra and Rt have been used for multiple generations [2]. Based on the early parameters, from the 1940s onwards, several 2Dmeasures were developed leading to a great many of parameters [2]. Nowadays, feature parameters for the characterization of profile topographies can be found in the standard ISO 4287:1997 [1]. These parameters enable a more function-oriented characterization of technical surfaces and are represented by the mean height of the profile elements Rc and the mean spacing of the profile elements RSm [1]. Both parameters are calculated based on the roughness profile. In ISO 4287:1997 a profile element is defined as a profile hill followed by a profile dale or a profile dale followed by a profile hill. The profile elements are separated by the zero crossings of the profile [1]. Unfortunately, the implementation of the parameters is not clearly defined in ISO standardisation and there is no reference algorithm so far. Due to this, a comparability of the results of different measurement devices or different evaluation software respectively, is not ensured. While the parameter definition has been subject of previous research [11] the algorithmic implementation of it has not yet been described to full extent. Furthermore, in ISO 4287:1997 RSm is actually defined as mean width of profile elements, as already described in section 1, but the following algorithm will calculate profile element spacing, as will be part of the revised definition in ISO 21920.
The crossing-the-line algorithm now allows an unambiguous evaluation of the two parameters Rc and RSm. For both parameters, we recommend the following discrimination limits for the segmentation process: -The upper vertical limit H u shall be 10% of the roughness parameter Rp (distance between the highest hill and the reference line).
-The lower vertical limit H l shall be 10% of the roughness parameter Rv (distance between the deepest dale and the reference line).
-The upper limit O H for zero crossings shall be 0.01% of the roughness parameter Rp.
-The lower limit O D for zero crossings shall be 0.01% of the roughness parameter Rv.
In ISO 4287:1997 the vertical discrimination level is given with regard to a percentage of Rz (vertical distance between highest hill and deepest dale). As shown above, we propose to use different levels for positive and negative profile portions and to abandon horizontal discrimination. Furthermore, the parameters Rc and RSm depend on the direction of evaluation. This becomes clear when the number of hills and dales are unequal. The following definition for Rc and RSm respectively avoid this issue.
The way to calculate RSm and Rc: -Apply the crossing-the-line segmentation with appropriate threshold limits.
-After segmentation, the total number m of profile elements is given by = - (the operator q ⌊ ⌋ calculates the greatest integer less than or equal toq). Note: The first and last profile features are never considered to be part of any profile element and the total number m includes the elements of both evaluation directions.
-Allocate the profile element spacing Xs k and profile element height Zt k as follows • take into account the evaluation from the left to the right . , 1 , , 2 ., 1 , , 2 • take into account the evaluation from the right to the left . as recommended before. Eight dales (bricks) and seven hills (hatched areas) were detected. The profile features are numerated from 1 to 15. The grey filled area (between profile feature seven and eight) is identified as a zero element.
To be independent of the evaluation direction, the profile features are evaluated from the beginning to the end of the evaluation length, figure 6, and vice versa, figure 7. The evaluation starts (figure 6) with the second profile feature PF , 2 a hill. Consequently, the first profile element consists of profile feature PF 2 and PF . 3 Two profile features are always combined for the next profile element. The evaluation ends when no more profile elements can be formed. A total of six profile elements can be formed in this way. The spacing of the profile elements is given by the distance of the beginning of two consecutive profile elements (here the beginning of two consecutive hills). The height of each profile element is simply the addition of the heights of the two profile features involved. Figure 7 shows the evaluation of profile features from the right to left. The procedure is the same as described before. A special case concerns profile element 10. A zero element is enclosed by a hill and a dale and is therefore part of this profile element.

Case studies
After introducing the algorithm, its application will be discussed by describing multiple examples that serve as case studies for the crossing-the-line segmentation.
The first examples will describe artificial profiles to demonstrate properties of the implementation before actual engineering surfaces will be addressed. Figure 8 shows the evaluation of a sinusoidal profile with a wavelength of 1.2 mm and an amplitude of 1.0 μm. The algorithm recognizes seven profile features (four hills and three dales). The first and the last feature are border features (in this case both hills). They are deleted (indicated with the hatched areas) since they could possibly be part of larger features, which have been cut off due to the arbitrary starting point of the profile measurement. In the left to right evaluation the first dale and the second hill are combined to the first profile element (red). Furthermore the second dale and the third hill are combined to the second profile element (blue). Though it has not been deleted, the third (most right) dale cannot be assigned to a profile element, because there is no hill left over. The right to left evaluation on the other hand leaves out the most left dale respectively. The RSm parameter describes a profile element spacing of 1.2 mm, which in this case is equivalent to the wavelength.  The surface in figure 9 contains sinusoidal components interrupted by zero elements that are located either exactly on the reference line or at least between the height discrimination limits. In the very first step those zero elements are deleted (hatched areas). Again the first dale and last hill (border elements) are also deleted. In the left to right evaluation the first hill is combined with the second dale (red) and the second hill with the third dale (blue) to form profile elements. Since the RSm parameter evaluates profile element spacing (in opposite to width) the width of the central zero element (red and hatched) is included when calculating the spacing to the following profile element, although the zero element was deleted in the first place. In the same way the zero element that follows the second profile element (blue and hatched) is  included when calculating the spacing to the last (border) feature.
Because zero elements are deleted before the border features are addressed the very first and the very last hill in the profile in figure 10 are deleted although not being located at the border. Therefore only one profile element can be combined from the first dale and the second hill (left to right evaluation). The zero element between this dale and this hill, though deleted in the first place, is included within this profile element and also contributes to its width. As before, when calculating elements spacing, also the width of the zero element right of the profile element is taken into account. Figure 11 shows the merging of adjacent profile features of the same type. Therefore the first two and the last two hills are deleted as border features, after being merged into one feature each. Consequently the single profile element consists of two dales and two hills which have been merged into one dale and one hill. Over all, the ten features in this profile are merged pairwise to five features in the end.
Lowering the height discrimination limit for hills to zero allows for the evaluation of plateau like profiles, as shown in figure 12. Under the presence of noise, a plateau is recognized as a sequence of hills and zero elements which are merged into a single hill feature across the whole plateau. Depending on evaluation direction these plateaus are then combined with the adjacent grooves to profile elements. The current description of RSm would not detect any profile elements as there would be no hills detected with a threshold of 10 % of Rz. This also allows for deleting whole plateaus at the borders as border features instead of only deleting little fractions of it. Figure 13 shows a last example of artificial profiles with an entirely stochastic surface. It is constructed as white Gaussian noise with a 1 μm standard deviation. For example the resulting, small RSm-parameter of only 2.8 μm indicates a highly stochastic profile with quickly alternating and therefore short profile portions.
When slightly correlating neighbouring samples, one receives a profile with coloured noise. Though the resulting profile in figure 14 has roughly the same signal power (sum of squared samples) as the profile in figure 13, the RSm parameter has a steep increase with about factor 4. This indicates the reduction in randomness within the profile. Figure 15 shows a measured profile produced by a turning process. The RSm parameter represents the spacing of turning grooves on the mostly deterministic surface.
Finally figure 16 shows a measured profile of a honed surface. The similarities to the profile in figure 12 can be seen based on the distinct dales and the plateau-area with a stochastic height distribution. Consequently it is evaluated with a hill height discrimination limit of zero to allow the detection of the plateaus as hills. Figure 17 shows a measured profile of a sintered surface. The reference line for this kind of profile is determined with a morphologic filter to simulate the   contact partner. In this case the profile was morphologically closed by a disc as structuring element with a 0.8 mm radius. Table 1 gives an overview of the calculated RSmparameters for the different surfaces. It also shows the RSm-parameters calculated with an older implementation of ISO 4287:1997 for different horizontal discrimination limits. It is obvious that the new approach delivers equal or similar results for mostly deterministic surfaces like in figures 8 to 11 or 15. Furthermore it allows the evaluation of plateau-like surfaces like the ones in figures 12 or 17, which was not possible before. The results for figures 13 to 16 show a clear correlation between RSm and horizontal discrimination limit when applying the old implementation. There is no such ambiguity for the new algorithm.

Implementation
In appendix A, both a Matlab and Python code implementation of the previously given pseudo code that have been debugged and tested on various profiles are provided.

Conclusion
Crossing-the-line segmentation is a powerful tool to separate characteristic features of a profile. In this publication we have described an unambiguous core algorithm in pseudo code and have included an implementation in Matlab. A typical application for this algorithm is to calculate the feature parameters RSm and Rc defined in ISO 4287:1997. However, other parameters such as the number or spacings of particular features are also possible, just to give an example. The presented algorithm will be part of ISO 16610 part 45 and ISO 21920 part 2 which will be published in the next years. The Technical Report 23276 will also be published so that a document will soon be available at ISO level.  The required implementation by instrument manufactures in order to enable a comparable evaluation with different instruments can be based on the provided code in the Appendix or be implemented based on the presented Pseudo-code in any other programming language.