Your question may also be related to this.
This is a difficult problem. A possible way would be to implement the Euclidean distance yourself, completely abandon scipy and use the pypy JIT compiler. But, most likely, this will not make you think hard.
Personally, I would recommend you write a procedure in C.
The problem is not so much in implementation, but in how you approach this problem. You chose the brute force method by calculating the Euclidean distance for each individual pair of points in each possible pair of metric spatial subsets. This requires computational requirements:
- Suppose you have 500 curves, and each of them has 75 points. With brute force approach, you end up calculating the Euclidean distance 500 * 499 * 75 * 75 = 1,403,437,500 times. No wonder this approach runs forever.
I am not an expert in this, but I know that the Hausdorff distance is widely used in image processing. I suggest you familiarize yourself with the literature for algorithms with speed optimization. The starting point may be this , or this document, also often referred to in conjunction with the Hausdorff distance Voroni diagram .
I hope these links can help you with this problem.
jojo
source share