Influence of Noise on the DTW Metric Value in Object Shape Recognition

Influence of Noise on the DTW Metric Value in Object Shape Recognition Ivan M. Gostev*, Leonid A. Sevastianov† * Department of Management Information Systems and Digital Infrastructure National Research University “Higher School of Economics” 20, Myasnickaya str., Moscow, 101000, Russian Federation † Department of Applied Probability and Informatics Peoples’ Friendship University of Russia (RUDN University) 6, Miklukho-Maklaya str., Moscow, 117198, Russian Federation


Introduction
At identification of graphic objects there is a number of problems that need to be investigated first.One of such problems is the influence of noises on the quality of recognition.The use of methodology described in Refs.[1,2] is oriented on multiple stages of preliminary image processing aimed at extracting primary image features, such as contours, angles, texture, etc. [3,4].At the final stage, the object properties are compared with the sample object properties basing on a certain metric that allows the classification of objects.The object contour is known to be one of the most informative features of the object shape [5,6].Although the issues of contour receiving and mathematical description attract much attention, a significant role here is played by the recognition methods using signature analysis [7,8].It is based on the calculation of one-dimensional contour function from the two-dimensional array of the contour points with the use of the center of gravity of the studied object or, in some cases, without it.The process of identifying such one-dimensional contour function is identical to the analysis and comparison of time series data, since such contour function can be considered as an example of time series.
Time series data are widely used in many scientific and practical areas, such as recognition of speech and music, hand-written text, electrocardiograms, stock exchange quotations, in bioinformatics, etc.The use of Euclidean metric (as well as the   metrics) for their classification often leads to large errors.
In the present paper in order to identify the object shape after the preliminary processing of the image we use the algorithm ArcHeight, one of the signature analysis algorithms, by using which one gets a contour function considered further as a time series.We briefly present the principles of the classical algorithm DTW that underlies the comparison of time series data.The influence of noises on the value of DTW metric is theoretically analyzed.The results of simulations confirm the theoretical conclusion that the metric value is independent of noise values in a wide range of interval.Examples that show the area of applicability of the present method are presented.In the discussion, the advantages and disadvantage of the presented approach to the identification of contour functions are summarized.In conclusion, the direction of further studies in the field and the perspective of application are outlined.

Contour Function
Let us define a contour function as the result of a certain transformation of the 2d form (contour) object into a 1d function of the boundary representation.Most methods of constructing such functions are based on the signature analysis that uses the representation of the contour function with respect to the center of gravity [9].There are also methods that use contours, but do not use the center of gravity, which can be also considered as signature methods, e.g., the algorithms by Chetverikov [10], Rosenfeld [11], Mokhtarian [12] or the arc-chord distance method [13,14], later referred to as ArcHeight [15].
In the present paper the contour function of the object is obtained using the classical algorithm ArcHeight.This algorithm is based on calculating the length of the perpendicular from the middle of some segment of the curve (the object perimeter) to the chord connecting the end points of the segment.This perpendicular is calculated using the formula and is proportional to the value of curvature of the segment at the considered point [16].
The sequential tracing of the contour yields a certain tabulated function that characterizes the shape of the object.An example of such function for the silhouette of the aircraft JetCommander1121 is shown in Fig. 1. Figure 1.Silhouette of the aircraft JetCommander1121 with introduced noise at the level of 40 dB, its contour and its contour function calculated using the method ArcHeight.The number of contour points is 2064, the chord length is 35, the Savitzky-Golay filter length is 31 point In the left upper corner of Fig. 1 the silhouette is shown, the right upper corner shows the contour of this, and at the bottom the resulting contour function, obtained using the ArcHeight method is presented.To obtain the contour function we used the following sequence of operations: image loading, filtering, conversion into binary black-and-white image, morphological cleaning of the residual noise, contour receiving, using of the algorithm ArcHeight for the contour function calculation, and its smoothing using Savitzky-Golay method.
Since the size of the objects on the image can be different when applying the ArcHeight method, we used the technique of dynamical setting of the curve segment size to eliminate the size influence.Experiments have shown that the optimal value of the chord is  = /100 + 14, where  is the segment length and  is the total length of the contour in pixels.
Remark.To enhance the noise immunity of the method for large objects it is possible to use averaged values of coordinates of a few adjacent points rather than a single point as the end coordinates of the chord.

The Idea of DTW
Let us denote the contour functions of the object and the sample as the sequences of values  =  1 ,  2 , . . .,   , . . .,   and  =  1 ,  2 , . . .,   , . . .  , respectively, generally with  ̸ = , and let us consider these functions to be time series data, so that the adjacent values of each series have similar time shifts.For comparing these sequences in the classical DTW method the matrix of distances (deformations) (, ) with the dimensions  ×  is constructed, where each element (, ) of the matrix represents a certain distance (, ) between two points   and   .Commonly this distance is calculated as a Euclidean one, i.e.,

𝑑(𝑞
but it can be calculated as the norm (  ,   ) = |  −   | as well.Each element of the matrix corresponds to the flattened section between the points   and   .The purpose of the DTW algorithm is to construct a certain path  =  1 ,  2 , . . .,   , . . .,   , such that max(, )  <  +  + 1, obeying the following conditions: the boundary condition: for the initial and final points of the matrix diagonal  1 = (1, 1) and   = (, ); the continuity condition: for the adjacent points   = (, ) and   = ( ′ ,  ′ ) it is necessary that ( −  ′ ) 1 and ( −  ′ ) 1; the monotonicity condition: for the adjacent points and it is necessary that (− ′ ) 0 and ( −  ′ ) 0. From the theoretical variety of possible paths, the following one is chosen: In Eq.( 3), the divisor  is used to normalize the metric at different dimensions of the sequences  and .This path is found basing on dynamical programming by means of the formula where (, ) is the accumulated path length and (  ,   ) is the path length from the starting point to the point (, ).As a result, a certain number is obtained characterizing the distance between the sequences  and , which will be denoted by   .The left-hand one results from the comparison of two identical sequences SS (Sample-Sample), the middle one is obtained for a certain variation of one sequence with respect to another, and the right-hand one is obtained for different sequences SN (Sample-Non-Sample).The diagonal top-bottom line corresponds to the optimal path.The smaller is the deviation of this line from the diagonal, the smaller is the difference between the sequences.
Let us consider the problem of whether the minimal DTW path satisfies the definition of metric.For this aim, let us check the fulfilment of the metric requirements: the axiom of identity (, ) 0, the equality to zero corresponding to  = .Since the elements of the matrix of distances are calculated in an Euclidean space, it is obvious that each element of the matrix will be positive and, therefore, the condition is satisfied.When the sequences coincide, the distance along the principal diagonal will equal 0, since the Euclidean metric, calculated for each element of the diagonal, will be equal to zero; the axiom of symmetry (, ) = (, ).This condition is also obviously valid, since the permutation of positions in the metric means the transposition of the matrix of distances; the triangle inequality (, ) (, ) + (, ).Automatically follows from 1 and 2 being presented as (, ) (, ) + (, ).Thus, the use of the term "DTW metric" is fully justified.Let us define the identification function, based on the DTW method, as where   is the DTW metric, and  is the classification tolerance (CT) for the considered method.
Let us analyze some results of DTW metric calculations for realistic data.As an example, consider the contour functions of aircraft silhouettes presented in Fig. 3 1 .Table 1 presents the values of metrics calculated for all combinations of aircraft silhouettes in Fig. 3.At the principal diagonal, the values of DTW metric calculated for the aircrafts of the same name are located.For combinations of different planes (SN) we get the mean value  = 0.639 and the variance  = 0.045, which allows the conclusion that the mean value for sample-sample combinations is essentially smaller than for sample-non-sample combinations.This is an evidence of DTW metric efficiency in the object shape recognition.
One more issue of importance is the type of metric distribution under different distortions of the contour function.The simulation has shown that the distribution of the DTW metric value under the influence of noise occurs in accordance with the normal law.Thus, e.g., Fig. 4 presents a histogram of the metric values and the distribution density function calculated on its base for the Avro668 plane SS combinations.The metric value is different from zero, since in the process of investigation a noise was added on the plane silhouette that distorted the shape of the object and, finally, the contour function.The verification of the hypothesis of normal distribution has shown high accuracy of agreement with the parameters  = 0.192127;  = 0.001491.Multiple experiments with other silhouettes also confirm the normal distribution law for the values of metrics under the effect of noise.

Specific Features of DTW Metric Application
Under process identification real objects, their size and position with respect to the sample are not known in advance.Therefore, it is necessary to use some algorithmic method for correct matching of contour functions in the process of recognition.
Moreover, even for the rotation of a single object, the contour function shifts by a certain number of points corresponding to the rotation angle.An example of such contour functions with the cyclic shift by nearly 640 points for the silhouette of BoeingB47E is shown in Fig. 5.

Specific features of DTW metric application
Under process identification real objects, their size and position with respect to the sample are not known in advance.Therefore, it is necessary to use some algorithmic method for correct matching of contour functions in the process of recognition.
Moreover, even for the rotation of a single object, the contour function shifts by a certain number of points corresponding to the rotation angle.An example of such contour functions with the cyclic shift by nearly 640 points for the silhouette of BoeingB47E is shown in Fig. 5. Calculating the DTW metric for cyclically shifted contour functions from Fig. 6, we get the value 0.7174 , which corresponds to the SN combination for the compared contour functions.Since the orientation of the object silhouette, i.e., the shift of one contour function with respect to another is not known a priori, some operations are to be performed to resolve the problem.First, assume that the number of points of the sample exceeds that of the object to be recognized, i.e., mn  .Otherwise, we change the object for the sample and vice versa.Second, it is necessary to augment the sample from the right by the number of points, corresponding to the object, i.e., * Calculating the DTW metric for cyclically shifted contour functions from Fig. 6, we get the value   = 0.7174, which corresponds to the SN combination for the compared contour functions.Since the orientation of the object silhouette, i.e., the shift of one contour function with respect to another is not known a priory, some operations are to be performed to resolve the problem.First, assume that the number of points of the sample exceeds that of the object to be recognized, i.e.,  > .Otherwise, we change the object for the sample and vice verse.Second, it is necessary to augment the sample from the right by the number of points, corresponding to the object, i.e.,  * =  1 ,  2 , . . .,   ,  1 ,  2 , . . .,   .Third, it is needed to organize the sequential comparison of the object with the fragment of the augmented sample.In other words, we calculate the DTW as a function of the object position on the augmented function   of the sample in the form    (,   ()) = min , where   () =  * (  ,  +1 , . . .,  +−1 ), Here   at a certain  determines the value of shift of the window moved along the sample, in which the values of the DTW metric is calculated.The metric value will be calculated as   = min  (   (,   ())).

Noise Resistance
In the development of new methods for identification of the object shape one has to take the influence of different factors into account [17].One of them is the permanent presence of noises in the real image, which finally distorts the contour function.Let us estimate the influence of noises on the DTW metric value.
Let the contour function be presented as  =  1 ,  2 , . . .,   , . . .,   for the object and as  =   +   ,  = 1,  for the sample, where   is a certain value of the noise component distributed according to the normal law and added to each value of the numerical sequence.Let us substitute the values of  into Eq.( 2) and calculate the distance for each value of : In fact, the result of the calculation means that under the influence of noises the value of metric converges to the 2 law [18] 1 .According to the central limit theorem, when  converges to infinity for a large number of degrees of freedom , the distribution of the random variable  →  2 () can be approximated by the normal distribution, with parameters  =  (, 2), with  → ∞ (more exactly,  − √ 2 →  (0, 1)).Therefore, the value of metric in the sum of Eq. ( 6) for a large number point of sequence must tend to zero.Hence, the value of metric should not change under the addition of noises to the contour function in a wide range of the values, determining the shape of objects.
Let us verify this statement by simulation using the Matlab software.We impose random noise on the contour function (series), e.g., the one obtained from the silhouette of the AeroL29 aircraft, using the built-in function awgn that allows the addition of noises to an array of points with the level expressed in dB 2 .Let us calculate the values of metric using Eq. ( 4) with Eq. ( 6) taken into account, starting from the signal-to-noise ratio 100 dB and gradually reducing it to 3 dB with the step of 1 dB.The simulation results for three silhouettes of AeroL29, JetCommander1121, and MitchellD25C shown in Fig. 6 demonstrate that the metric remains unchanged practically until the noise level becomes comparable with the signal level.Basing on the considerations presented above, we conclude that the DTW metric is persistent against the noise in a wide range of values of noise.

Discussion and conclusion
The DTW metric offers wide possibilities of object shape recognition.The disadvatage of the algorithm include high computation complexity of calculating the metric O(mn) and, as a consequence, essential increase of the computation time for sequences of high dimensions.
High potentialities are related to the application of DTW metric to the recognition of graphical objects shape.The capabilities of DTW allow the identification of objects, for which the description is based on the nonlinear variation of the contour function step that occurs in the case of object shape distortion.In these cases, the metrics of the Lp type are inapplicable.The analysis of the DTW metrics demonstrates its resistance against the noise, which significantly extends the area of its application.Besides the identification of the object shapes, this metric is widely used in speech recognition, in medicine, bioinformatics, and economics in the analysis of trends, where the parasitic noise level can be very high, etc.
The work was supported by the Russian Foundation for Basic Research, grant No. 16-07-00556.Basing on the considerations presented above, we conclude that the DTW metric is persistent against the noise in a wide range of values of noise.

Discussion and Conclusion
The DTW metric offers wide possibilities of object shape recognition.The disadvantage of the algorithm include high computation complexity of calculating the metric O(mn) and, as a consequence, essential increase of the computation time for sequences of high dimensions.
High potentialities are related to the application of DTW metric to the recognition of graphical objects shape.The capabilities of DTW allow the identification of objects, for which the description is based on the nonlinear variation of the contour function step that occurs in the case of object shape distortion.In these cases, the metrics of the Lp type are inapplicable.The analysis of the DTW metrics demonstrates its resistance against the noise, which significantly extends the area of its application.Besides the identification of the object shapes, this metric is widely used in speech recognition, in medicine, bioinformatics, and economics in the analysis of trends, where the parasitic noise level can be very high, etc.

Figure 2 .
Figure 2. Three matrices of distance and the calculated paths for comparison of objects: EE (left); EE with distortion of one of the objects (middle), EN (right)

Figure 4 .
Figure 4. Histogram and metric distribution density function for the Avro668 plane SS combinations

Fig. 5 .
Fig. 5. BoeingB47E aircraft silhouettes (reduce) with different angle of rotation and their contour functions with cyclic shift.

Figure 5 .
Figure 5. BoeingB47E aircraft silhouettes (reduce) with different angle of rotation and their contour functions with cyclic shift