This paper formalizes smooth curve coloring (i.e., curve identification) in the presence of curve intersections as an optimization problem, and investigates theoretically properties of its optimal solution. Moreover, it presents a novel automatic technique for solving such a problem. Formally, the proposed algorithm aims at minimizing the summation of the total variations over a given interval of the first derivatives of all the labeled curves, written as functions of a scalar parameter. The algorithm is based on a first-order finite difference approximation of the curves and a sequence of prediction/correction steps. At each step, the predicted points are attributed to the subsequently observed points of the curves by solving an Euclidean bipartite matching subproblem. A comparison with a more computationally expensive dynamic programming technique is presented. The proposed algorithm is applied with success to elastic periodic metamaterials for the realization of high-performance mechanical metafilters. Its output is shown to be in excellent agreement with desirable smoothness and periodicity properties of the metafilter dispersion curves. Possible developments, including those based on machine-learning techniques, are pointed out.