Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate the "difference" between two sequences of points?

I have two sequences of length n and m. Each is a sequence of points of the form (x,y) and represent curves in an image. I need to find how different (or similar) these sequences are given that fact that

  1. one sequence is likely longer than the other (i.e., one can be half or a quarter as long as the other, but if they trace approximately the same curve, they are the same)
  2. these sequences could be in opposite directions (i.e., sequence 1 goes from left to right, while sequence 2 goes from right to left)

    I looked into some difference estimates like Levenshtein as well as edit-distances in structural similarity matching for protein folding, but none of them seem to do the trick. I could write my own brute-force method but I want to know if there is a better way.

Thanks.

like image 828
WanderingPhd Avatar asked Jun 20 '11 21:06

WanderingPhd


People also ask

What is the formula to find difference in a sequence?

Common Difference Formula Therefore, the formula to find the common difference of an arithmetic sequence is: d = a(n) - a(n - 1), where a(n) is nth term in the sequence, and a(n - 1) is the previous term (or (n - 1)th term) in the sequence.


1 Answers

Do you mean that you are trying to match curves that have been translated in x,y coordinates? One technique from image processing is to use chain codes [I'm looking for a decent reference, but all I can find right now is this] to encode each sequence and then compare those chain codes. You could take the sum of the differences (modulo 8) and if the result is 0, the curves are identical. Since the sequences are of different lengths and don't necessarily start at the same relative location, you would have to shift one sequence and do this again and again, but you only have to create the chain codes once. The only way to detect if one of the sequences is reversed is to try both the forward and reverse of one of the sequences. If the curves aren't exactly alike, the sum will be greater than zero but it is not straightforward to tell how different the curves are simply from the sum.

This method will not be rotationally invariant. If you need a method that is rotationally invariant, you should look at Boundary-Centered Polar Encoding. I can't find a free reference for that, but if you need me to describe it, let me know.

like image 129
Luke Postema Avatar answered Oct 01 '22 03:10

Luke Postema