[SciPy-User] How to do symmetry detection?

Charles R Harris charlesr.harris at gmail.com
Wed Jan 20 12:15:47 EST 2010


On Wed, Jan 20, 2010 at 8:20 AM, iCy-fLaME <icy.flame.gm at gmail.com> wrote:

> Hello,
>
> I have some signals in mirror pairs in an 1D/2D array, and I am trying
> to identify the symmetry axis.
>
> A simplified example of the signal pair can look like this:
> [0, 0, 0, 0, 2, 3, 4, 0, 0, 0, 4, 3, 2, 0]
>
>
In [8]: a=np.array([0, 0, 0, 0, 2, 3, 4, 0, 0, 0, 4, 3, 2, 0])

In [9]: center = np.convolve(a,a).argmax()*.5

In [10]: center
Out[10]: 8.0

In [11]: a[center - 4: center + 5]
Out[11]: array([2, 3, 4, 0, 0, 0, 4, 3, 2])

Essentially this computes the component of the original along the reversed
version for different shifts looking for the best match. The center can be
between two indices which is why it is computed as a float

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100120/ab69832f/attachment.html>


More information about the SciPy-User mailing list