-
Notifications
You must be signed in to change notification settings - Fork 42
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 BiasCorr
classes and rename previous coreg.BiasCorr
in coreg.VerticalShift
#158
Conversation
Update upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!! I think some existing Coreg classes should be in biascorr.py
as well. What do you think, @adehecq?
Oh, and there's no |
Seems to be in good shape! I guess you're still waiting to merge #151 before moving further? |
BiasCorr
classes, refactor previous Coreg.BiasCorr
in Coreg.VerticalShift
Merged with #346 |
Hi @rhugonnet, This is really the right way forward and I'm grateful that you've spent so much time improving this! While I do have questions on the current setup, I think splitting the Coreg class into rigid/nonrigid methods may be very useful.
Adding a I'll do a code review as well soon (hopefully today). These were just ideas from reading the documentation and your comments! Again, I'm really excited for this improvement! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the largest PR to date? :P
The coreg.py diff has become messed up since things have moved up and down. Therefore it was hard for me to evaluate the last 1/3 of the changes. I guess I'll just have to trust you! If tests pass, however, it can't be that wrong ;)
doc/source/biascorr.md
Outdated
- **Supports weights** Yes. | ||
- **Recommended for:** Residuals from camera model. | ||
|
||
Deramping works by estimating and correcting for an N-degree polynomial over the entire dDEM between a reference and the DEM to be aligned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below it's called deramping, while the class itself is now called TerrainBias. It also brings up what I mentioned before about the horizontal scaling, making it non-rigid.
Oh yeah. What if instead of |
Thanks a lot @erikmannerfelt for the thorough read and comments! All accounted for 🙂 We just need to decide on names! I agree with all of your replies 1. to 6. above! More specifically:
Looking into the computer vision/DEM literature, it looks like "alignment", "registration" or "co-registration" are synonyms largely used for all kind of transformations (affine and not affine, see https://en.wikipedia.org/wiki/Image_registration). However, nonaffine methods generally imply a certain type of "spatial deformation" is used (spline, quadric, etc...), which is not the case for all of our current So, in short, I see two "base name" options for the parent classes: 1. Data-centered (we refer to the nature of the inputs = two DEMs): 2. Objective-centered (we refer to the pipeline objective that is co-registration): And for the structure, could be:
or we could differentiate non-affine registration methods and "bias correction" methods, considering non-affine registration methods are only using the spatial dimension?
What do you think @erikmannerfelt @adehecq? |
Hey,
I'm happy to have a more detailed look at the code later, but again, given that it's a very large PR and will take a significant amount of time, I'd rather do it on a close-to-final version. Plus, @erikmannerfelt already made a first round and I don't think I can compete in term of Python rigorousness 😄 |
I like @adehecq's suggestion on the structure! Depending on the new file length (since the
where the new Thoughts? I'm fine with either @rhugonnet, when this is figured out, I think we should finally merge!! |
Thanks both for the great inputs! 😄 I initially agreed with everything and tried to move forward, but then realized there's an issue with this structure 😅: our processing steps and pipelines as they stand are not generic, but specific to two DEMs later differenced, or a DEM and point data, and expect these inputs. So, for instance, we wouldn't be able to apply the same So we'd need to clearly define to what objects the "steps" and "pipelines" refer to. As of now, we just have things that work on In short:
What do you think? I hope I didn't miss anything. If you are both fine with the naming, you can just send a 👍 and I'll start making the changes related to this PR. I agree @erikmannerfelt, we should merge this soon! |
Let's do that then ! Ok for the order. It also sounded strange to me, but it made more sense to me if we had for example coreg and filters living in the same submodule, because then it would be easier to identify each category (e.g. if we had xdem.AffineCoreg, xdem.GlobalFilter, xdem.NonAffineCoreg etc it would be puzzling). Because they live in two different submodules, it's fine. |
Re-structuration done according to comments! Two points:
After more than 2 years... merging! 🥳 |
Summary
This PR adds non-rigid co-registration "bias-correction" methods through the class
BiasCorr
and subclasses located inbiascorr.py
! 😄In details, this PR:
coreg.BiasCorr
intocoreg.VerticalShift
.Coreg
parent class intoRigid
, as all of its methods (to_matrix
, etc) and its subclasses are only relevant for rigid transformations,Coreg
that contains only the generic methods to any processing step (e.g.,residuals()
) and is subclassed byRigid
for rigid transforms,BiasCorr
for non-rigid transforms, andCoregPipeline
andBlockwiseCoreg
to be able to use those with any subclass ofCoreg
(can now do a pipeline with aCoreg
method and aBiasCorr
method, for example, and any other class we choose to add belowCoreg
),Coreg.fit()
into a separate_preprocess
function, and usessubsample_raster
from GeoUtils to consistently subsample the inputs,fit.py
to be consistent in the way they return optimized parameters and accept userkwargs
,BiasCorr
class: the user can either pass anyfit_func
(e.g.,np.polyval
) andfit_optimizer
(e.g.,scipy.optimize.curve_fit
) functions to determine a parametric solution to their bias, or anybin_sizes
(e.g.,10
),bin_statistic
(e.g.,np.nanmedian
) andbin_apply_method
(e.g., "linear" interpolation) to determine an empirical solution to their bias, or to do both (recommended option)!Deramp
,DirectionalBias
andTerrainBias
to allow user to easily run the classes without customization,fit.py
andcoreg.py
,test_biascorr.py
with many tests using synthetic biases,coreg.py
is updated, see thoughts below),coreg.py
is updated).TO-DO:
Deramp
intoTilt
incoreg.py
, and fix degree to1
(pointing toDeramp
for degree > 1 ?),bin_and_fit
to simplify big data problems,BiasCorr
(to streamline later with updatedCoreg
?),BiasCorr
(to streamline later with updatedCoreg
?).Thoughts on
Coreg
moving forwardWe should probably copy the same logic in
Rigid
classes:But this should probably live in a separate PR! 😅
Old draft text below