-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adding smoothing splines #102
Comments
Hi Kevin, yes this is definitely in the scope of BSplineKit.jl and I've been wanting to add this for a while. I'm not yet very familiar with how to implement smoothing splines based on a smoothing parameter, but I guess it shouldn't be too difficult. Also, I'm not yet sure about how they generalise to non-cubic splines (most implementations seem to be for cubic splines only). But that's ok, having cubic smoothing splines would be better than nothing. As you probably know, an alternative approach consists in simply reducing the number of degrees of freedom (= number of knots) of the resulting spline compared to the input data. It would be quite easy to provide an interface for this. The problem is that the result is quite dependent on the choice of knots. I think this is sometimes called regression splines. |
@jipolanco Great. Something like the R or MATLAB implementation there would be very useful! They other projects I linked to might offer insight into how to implement, and having it just for cubic splines for the moment seems fine. I am not an expert on the maths involved but happy to help create/add test cases etc. |
In fact I got a working implementation in #103. It seems to give exactly the same results as the SmoothingSplines.jl package (even though I didn't look at their code in detail), which is a good sign. I just need to add some tests and then it should be merged. |
The implementation is now included in the latest release, v0.18.0. It's quite simple to use, you can find some examples in the docs. Let me know if you have any thoughts! |
@jipolanco This is great thanks! I'll test it shortly! What do you make of MATLAB's implementation with the |
@Kevin-Mattheus-Moerman In fact MATLAB's formulation is equivalent to the one we use as long as their What can be interesting about MATLAB's formulation is that their roughness parameter A minor issue is that having an arbitrary In practice it wouldn't be too difficult to accept a variable |
I have never used the varying |
Sorry I wasn't very clear. What I meant is that, if one takes MATLAB's expression (let's call it X) and then divides the whole thing by
Well, if I'm not wrong the problem is actually ill-posed for |
Hmmm I get what you meant now. Your implementation seems to make more sense then. No strong feelings on either implementations. I'll test this now shortly. Actually, on that, I'm going to test it on closed loops. Do you have an example for these smoothing splines whereby the input is treated as periodic? |
Well, the |
Periodic conditions are now supported on v0.18.1. You can also find some examples here. Let me know if you have any remarks! |
Fantastic! The force is strong with this one. |
@jipolanco so you can see what it can be used for: smoothing contour lines for medical image segmentation. Works like a charm. segment_01.mp4 |
@jipolanco Do you think it would be in scope for this project to add smoothing splines?
Here are some other/related implementations:
https://github.com/nignatiadis/SmoothingSplines.jl
https://github.com/robertdj/SmoothSpline.jl
https://github.com/JuliaMath/Dierckx.jl (Based on a Fortran wrapper)
https://github.com/francescoalemanno/KissSmoothing.jl
MATLAB implementation:
https://www.mathworks.com/help/curvefit/csaps.html
R Implementation:
https://www.rdocumentation.org/packages/DescTools/versions/0.99.49/topics/SmoothSpline
The text was updated successfully, but these errors were encountered: