Dynamic clustering-based method for shape recognition and retrieval