fix rotating for ellipse fit#2482
Conversation
55128a0 to
36a1614
Compare
skimage/measure/fit.py
Outdated
| try: | ||
| M = np.linalg.inv(C1).dot( | ||
| S1 - np.dot(S2, np.linalg.inv(S3)).dot(S2.T)) | ||
| except: # LinAlgError: Singular matrix |
There was a problem hiding this comment.
Please, be more strict on the exception you catch. Otherwise, you'll catch everything and errors can't be detected.
There was a problem hiding this comment.
Could you had a test that make sure that the exception will be raised and the final behavior is correct?
There was a problem hiding this comment.
well, the are two points, it anything happens during slowing this matrix multiplication, goes to not proper ellipse fitting and then the estimate fails anyway... second, I found this instability while testing ransac on real data so isolating the special case is possible but not common... :)
skimage/measure/fit.py
Outdated
| @@ -515,7 +528,11 @@ def estimate(self, data): | |||
| C1 = np.array([[0., 0., 2.], [0., -1., 0.], [2., 0., 0.]]) | |||
|
|
|||
| # Reduced scatter matrix [eqn. 29] | |||
There was a problem hiding this comment.
move this comment after the try statement.
|
Has the bug been introduced in your last patch? namely commit d07592c |
|
excuse me, not sure what you mean by have been introduced in.. |
36a1614 to
3cb694c
Compare
skimage/measure/fit.py
Outdated
|
|
||
| xc, yc, a, b, theta = params | ||
| if isinstance(theta, complex): | ||
| theta = np.real(theta) |
There was a problem hiding this comment.
I just saw that np.real returns a 0-dimensional array. Do we want to cast to float? And do we want to do this anyway? It might be faster to pipe all values through float(np.real(theta)) than it is to check first. Thoughts?
skimage/measure/fit.py
Outdated
| ------- | ||
|
|
||
| >>> xy = EllipseModel().predict_xy(np.linspace(0, 2 * np.pi, 25), | ||
| ... params=(10, 15, 4, 8, np.deg2rad(30))) |
There was a problem hiding this comment.
Minor: fix indent to match open paren
f9a170e to
d60ebe5
Compare
skimage/measure/fit.py
Outdated
| Ellipse model parameters in the following order `xc`, `yc`, `a`, `b`, | ||
| `theta`. | ||
|
|
||
| Example |
|
I looked at the history, the answer to my question is yes. So we should merge it for 0.13. |
d60ebe5 to
4d6f110
Compare
Codecov Report
@@ Coverage Diff @@
## master #2482 +/- ##
==========================================
+ Coverage 90.74% 90.76% +0.01%
==========================================
Files 304 304
Lines 21665 21678 +13
Branches 1867 1870 +3
==========================================
+ Hits 19660 19676 +16
+ Misses 1662 1661 -1
+ Partials 343 341 -2
Continue to review full report at Codecov.
|
skimage/measure/fit.py
Outdated
| `theta`. | ||
|
|
||
| Examples | ||
| ------- |
There was a problem hiding this comment.
Travis is unhappy about this docstring — I'm not sure if it's because there is a missing - at the end to make the dashes' width equal to that of "Examples".
* fix crashes * add doctest example * update coverage * update review * update complex
4d6f110 to
d61e810
Compare
|
Good work, thanks! |
Description
fixing issue with estimated orientation, the equation was not implemented properly
Checklist
References
http://mathworld.wolfram.com/Ellipse.html#eqn23