|
Algorithm 2: Dynamic time warping. |
| 1: Input:
|
| 2: : template segment, with sampling points to . |
| 3: s: segment for recognition, whose class is unknown, with sampling points to . |
| 4: Output:
|
| 5: d: DTW distance between s and . |
| 6: normalize the amplitude of each sampling point in s into [-1, 1]; |
| 7: normalize the amplitude of each sampling point in into [-1, 1]; |
| 8: = 0; |
| 9: for
i = 1 to
do
|
| 10: = +∞; |
| 11: end for
|
| 12: for
j = 1 to
do
|
| 13: = +∞; |
| 14: end for
|
| 15: for
i = 1 to
do
|
| 16: for
j = 1 to
do
|
| 17: = ; |
| 18: = + min, , ; |
| 19: end for
|
| 20: end for
|
| 21: d = ; |