The Earth Mover's Distance as a Metric for Image Retrieval