Efficient Computation of Complex Distance Metrics Using Hierarchical Filtering