-
Notifications
You must be signed in to change notification settings - Fork 315
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
Fix projection for images with non-centered camera (e.g. crops) #305
Fix projection for images with non-centered camera (e.g. crops) #305
Conversation
The current code assumes [cx,cy] are at [w/2, h/2], if this is not the case (very common if you want to render a non-centered crop) the code gives VERY bad and incorrect results. This quick fix uses the proper [cx, cy].
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.
Wow, nice. LGTM!
Any reason the backward (persp_proj_vjp) is not updated? |
This seems a major bug. Could you also fix the backward pass as well? BTW, we also need to publish this fix to 0.1.xx version. |
can we do this instead, without modifying the rasterizer? graphdeco-inria/gaussian-splatting#144 (comment) |
Can someone explain why the clamping? The original 3DGS code has it too, and a comment says:
But EWA splatting has no clamping. What it does is that it clamps the 2D expansion (due to the projection) of Gaussians that are outside of the view frustum. My guess is that it's something that was introduced at some point, maybe to fix a visual artifact, and left there for no reason (maybe that artifact was due to something else). I can understand the reason for clamping, when considering very large Gaussians: The projection cannot be considered to be affine anymore, and maybe the clamping was introduced to avoid very large Gaussians that are outside of the view frustum to come inside the view frustum because of the affine approximation, which is computed at the center of the Gaussian and not at the "side" of the Gaussian that is closer to the view frustum. But then why treat Gaussians that are outside and not those that are inside? The projection of Gaussians that are inside should actually be larger (that same Jacobian is higher on the sides of Gaussians that are at the principal point). I think the correct fix is to remove the clamping. |
@liruilong940607 yes this probably needs to be changed in the backward pass too! I don't have time to look into this myself right now though unfortunately. @hbb1 The function you linked doesn't fix this issue, this actually needs to be changed in the cuda like suggested in this PR. @f-dy 'Why clamping': If you do nothing, the 'approximate jacobian projection' of Gaussians out to the side of field of view make these (normally small) Gaussians very large and project into the field of view and results in complete mess (no good image at all), so we absolutely need to do something about this. There are two solutions: b) (done here) make the Gaussians outside of field of view smaller (e.g. clip their size to the size it would be if they were 1.3fov away). The advantage of this over (a) is that if you have VERY large Gaussians outside of 1.3fov that actually SHOULD contribute to the image, in this setting they are able to, whereas if you just completely removed them as in (a) they wouldn't be able to contribute. Note that in (b) there is still culling of Gaussians to only those in the frustum, but the culling is not based on the center of gaussian location, but the projected 2D bounding box of the Gaussian (based upon the clipped projection here). Let me know if this makes sense? Note @f-dy if you naively try your solution to remove the clamping alone, you will get absolutely rubbish results (blury image that looks NOTHING like the scene) because all the Gaussians out to the side are basically filling the whole image with their (incorrect because of linear approximation) projection. |
I just finished the backward pass fix as well as the torch impl fix. cc for review @maturk @JonathonLuiten @jb-ye |
I checked the tests/ locally, all tests passed |
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.
lgtm
sorry to bother you guys!thanks for your incredible work of art.may i |
The current code assumes [cx,cy] are at [w/2, h/2], if this is not the case (very common if you want to render a non-centered crop) the code gives VERY bad and incorrect results. This quick fix uses the proper [cx, cy].