@@ -18,21 +18,37 @@ Usage
1818
1919 $ pip install pyefd
2020
21- Given a closed contour of a shape, this package can fit a
22- [Fourier series](https://en.wikipedia.org/wiki/Fourier_series)
21+ Given a closed contour of a shape, generated by e.g. `scikit-image <http://scikit-image.org/ >`_
22+ or `OpenCV <http://opencv.org/ >`_, this package can fit a
23+ `Fourier series <https://en.wikipedia.org/wiki/Fourier_series >`_
2324approximating the shape of the contour::
2425
2526 from pyefd import elliptic_fourier_descriptors
2627 coeffs = elliptic_fourier_descriptors(contour, order=10)
2728
28- The coefficients returned are the :math: `a_n`, :math: `b_n`, :math: `c_n` and :math: `d_n` of
29- the following Fourier series representation of the shape:
29+ The coefficients returned are the `a_n `, `b_n `, `c_n ` and `d_n ` of
30+ the following Fourier series representation of the shape.
3031
31- .. math ::
32- \begin {align*}
33- \hat {x}(t) & = A_0 + \sum _{n=1 }^N\left ( a_n \cos \frac {2 n\pi t}{T} + b_n \sin \frac {2 n\pi t}{T} \right )
34- \hat {y}(t) & = C_0 + \sum _{n=1 }^N\left ( c_n \cos \frac {2 n\pi t}{T} + d_n \sin \frac {2 n\pi t}{T} \right )
35- \end {align*}
32+ The coefficients returned are by default normalized so that they are
33+ rotation and size-invariant. This can be overridden by calling::
34+
35+ from pyefd import elliptic_fourier_descriptors
36+ coeffs = elliptic_fourier_descriptors(contour, order=10, normalize=False)
37+
38+ Normalization can also be done afterwards::
39+
40+ from pyefd import normalize_efd
41+ coeffs = normalize_efd(coeffs)
42+
43+ To use these as features, one can write a small wrapper function::
44+
45+ def efd_feature(contour):
46+ coeffs = elliptic_fourier_descriptors(contour, order=10, normalize=True)
47+ return coeffs.flatten()[3:]
48+
49+ If the coefficients are normalized, then `coeffs[0, 0] = 1.0 `,
50+ `coeffs[0, 1] = 0.0 ` and `coeffs[0, 2] = 0.0 `, so they can be disregarded when using
51+ the elliptic Fourier descriptors as features.
3652
3753See \[ 1\] for more technical details.
3854
@@ -43,7 +59,7 @@ Run tests with::
4359
4460 $ python setup.py test
4561
46- or with [ Pytest]( http://pytest.org/latest/) ::
62+ or with ` Pytest < http://pytest.org/latest/ >`_ ::
4763
4864 $ py.test tests.py
4965
@@ -53,13 +69,14 @@ for testing.
5369Documentation
5470-------------
5571
56- See the [ Github pages]( http://hbldh.github.io/pyefd) .
72+ See the ` Github pages < http://hbldh.github.io/pyefd >`_ .
5773
5874References
5975----------
6076
61- \[ 1\] [ Frank P Kuhl, Charles R Giardina, Elliptic Fourier features of a closed contour,
77+ \[ 1\] ` Frank P Kuhl, Charles R Giardina, Elliptic Fourier features of a closed contour,
6278Computer Graphics and Image Processing, Volume 18, Issue 3, 1982, Pages 236-258,
63- ISSN 0146-664X, http://dx.doi.org/10.1016/0146-664X(82)90034-X.](http://www.sciencedirect.com/science/article/pii/0146664X8290034X)
79+ ISSN 0146-664X, http://dx.doi.org/10.1016/0146-664X(82)90034-X. <http://www.sci.utah.edu/~gerig/CS7960-S2010/handouts/Kuhl-Giardina-CGIP1982.pdf> `_
80+
6481
65- \[ 2\] [ LeCun et al. (1999): The MNIST Dataset Of Handwritten Digits]( http://yann.lecun.com/exdb/mnist/)
82+ \[ 2\] ` LeCun et al. (1999): The MNIST Dataset Of Handwritten Digits < http://yann.lecun.com/exdb/mnist/ >`_
0 commit comments