-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ellipse fitting example #3895
Conversation
This looks like a super cool (and visual) example. No problem adding the extra packages. Just ensure they have a compat: Line 42 in 488a0db
Also: we need to make sure that the image we use can be redistributed. If possible, find the original source, instead of new scientist? |
Yeah JWST really creates some breathtaking images!
Found the source: https://webbtelescope.org/contents/media/images/2022/039/01G8JXN0K2VBQP112RNSQWTCTH
I'll make sure we add the acknowledgment. |
@odow I tested it locally, it should run. I have tried to follow the style guide based on other examples but might have missed something. Maybe good to check if all the MOI calls are correct, and you will probably spot some improvements in |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3895 +/- ##
=======================================
Coverage 99.58% 99.58%
=======================================
Files 43 43
Lines 6043 6043
=======================================
Hits 6018 6018
Misses 25 25 ☔ View full report in Codecov by Sentry. |
All comments should be addressed now. |
@odow Thanks for pushing it across the finishline! Seems like it's almost ready, let me know if I can do anything else. Just curious, but why did the solver change to Clarabel? |
I changed to Clarabel because SCS wasn't solving the final problem; it was hitting an iteration limit. (As an aside, you must always check the termination condition of a solver before accessing the solution.) But it seems like even Clarabel has trouble. |
You can try changing epsilon from 1e-5. This is the numerical issue with the SPD matrix constraint I was talking about on slack. |
What happens if we just drop the constraint? Then you might end up with an ellipse with zero area? |
Mathematically that doesn't make sense I think: https://en.m.wikipedia.org/wiki/Matrix_representation_of_conic_sections I believe I tried this and it just produced trivial forms of the quadratic equation. I think what we should do is fix the scale to 1. This means we constrain the determinant of Q to be 1. There is probably a way to do that with MOI. Maybe MOI.logdetconetriangle or similar? I'll check tomorrow if you haven't already (I'm in EUW timezone ;) ) |
It's not that SCS now fails. It didn't work before (it hit an iteration limit). It was just luck that the primal solution that SCS terminated with looked okay.
Different solvers different algorithms 😄 |
Thanks! That took a while to get right, but we got there in the end 😄 |
Yay! Thanks for finishing it. I learned a lot again. |
Draft PR for the ellipse fitting example, will add code.
For this demo I took an image of the cartwheel galaxy captured by the James Webb space telescope:
James Webb Space Telescope images
It's a very general setup and multiple ellipse model definitions, optimization criteria and demo images can be defined.
To efficiently fit the ellipses I need to do some image preprocessing, some filtering and some clustering. For these tasks I used
Clustering.jl
,Images.jl
andDSP.jl
. Would it be okay to use these dependencies? I can come up with alternative implementations but it will be more messy.After fitting the ellipses the final result looks like this: