Skip to content

TSDF Integrate truncates the depth lookup, biasing every sample half a pixel against its own projectionΒ #7580

Open

Description

@patrikhuber

Checklist

Describe the issue

Note: This was found by Claude Code while I was working on a related thing. I haven't traced through the whole code here myself, but I think this looks like a genuine indexing/rounding bug.

Two files in the same kernel disagree about the pixel convention.

cpp/open3d/t/geometry/kernel/GeometryIndexer.h, TransformIndexer::Project:

  *u_out = fx_ * x_in * inv_z + cx_;
  *v_out = fy_ * y_in * inv_z + cy_;

This is the standard pinhole model, in which an integer coordinate is the CENTRE of a pixel.

cpp/open3d/t/geometry/kernel/VoxelBlockGridImpl.h, Integrate, then samples the depth map with:

  index_t ui = static_cast<index_t>(u);
  index_t vi = static_cast<index_t>(v);
  float depth = *depth_indexer.GetDataPtr<input_depth_t>(ui, vi) / depth_scale;

static_cast truncates. Under the centre convention the nearest pixel to u is round(u), so
truncation selects the pixel to the left and above, biasing every depth lookup by -0.5 px on
average, and up to -1 px.

Truncation would be correct under a corner-origin convention, but Project does not use that. So
this is an internal inconsistency rather than a convention choice.

Steps to reproduce the bug

Read the two files above; the inconsistency is visible without running anything.

I guess to see the effect, one could integrate a synthetic depth map of a plane with a known pose, then compare the extracted surface against the analytic plane. The reconstructed surface should show displaced consistently with a half-pixel sampling bias, with the displacement growing with the depth gradient across the image.

Error message

No response

Expected behavior

The depth lookup should round rather than truncate, to match Project's convention:

  index_t ui = static_cast<index_t>(roundf(u));
  index_t vi = static_cast<index_t>(roundf(v));

with the bounds test adjusted accordingly. Claude says bilinear sampling would be better still, but rounding
is the minimal fix that makes the two files consistent.

Open3D, Python and System information

- Operating system: Windows / Ubuntu 24.04 (WSL)
- Python version: 3.11.13
- Open3D version: 0.19.0
- System architecture: x86_64
- Is this a remote workstation?: no
- How did you install Open3D?: built from source & conda
Note: the source quotes above are from current main, not 0.19.0, and the lines are unchanged between them.

Additional information

No response

Activity

  1. added
    bug
    on Sep 21, 2026
  2. patrikhuber commented on Sep 21, 2026

    @patrikhuber
    ContributorAuthor

    Asked Claude to reproduce this "visually":

    Integrate one synthetic depth image of a plane, extract the surface, and measure how far it is from where the plane actually is.

    tilt Β¦ depth change per pixel Β¦ error
    0 0.00 mm 0.00 mm
    10 0.34 0.17
    20 0.69 0.35
    30 1.10 0.55
    40 1.60 0.89
    50 2.27 1.27
    55 2.72 1.31

    The error is half the depth change per pixel, every time. A plane facing the camera has no depth change across pixels and comes out exactly right, which rules out the voxel grid and the extraction. Sampling the depth map at (i + 0.5, j + 0.5) instead removes it: 1.31 mm becomes 0.05 mm.

    Image
  3. kvnloo commented on Sep 24, 2026

    @kvnloo

    Thanks @patrikhuber for the report. One possible follow-up: would a small shared helper for nearest-pixel selection be useful here?

    The tensor paths currently differ in both rounding and check order: TSDF depth checks bounds then truncates, TSDF color checks bounds then rounds, while point-cloud projection and the point-to-point / point-to-plane odometry paths round before checking bounds.

    Rather than wrapping roundf() alone, the helper could return valid integer pixel coordinates or failure, keeping rounding, bounds, and non-finite-coordinate handling together. Projection and each caller's depth/color validity rules would remain separate.

    One behavior worth agreeing on first is the image edge. InBoundary() currently checks through width - 1, so checking before rounding rejects coordinates such as 639.4 in a 640-pixel image, even though the nearest pixel is 639. Adopting round-then-check across callers would therefore need explicit edge tests, not just a mechanical refactor.

    I'd keep the immediate depth fix independently reviewable, then consider this helper for the tensor paths that should share the same nearest-pixel contract. Bilinear sampling, legacy color-map warping/margins, and the renderer convention question in #7579 would stay outside that change.

    Would that scope be useful, or would you prefer keeping these few lines local with matching regression tests?

    AI-assisted source review; no new runtime tests run for this follow-up.

  4. kvnloo commented on Sep 24, 2026

    @kvnloo

    Thanks @patrikhuber for adding the plot! the way the error grows with the depth change between neighboring pixels supports the suspected sampling bias.

    I think this complements a small pixel-selection regression nicely: the small test checks which pixel gets read, while your tilted-plane experiment checks the effect on the reconstructed surface.

    Could you share the script used to generate the plot? For validating the fix, it would be useful to keep the synthetic depth image, calibration, and reconstruction settings identical between runs, changing only the lookup in Open3D. That would distinguish correcting the integration code from compensating for the mismatch when generating the input.

    I'd keep the camera-facing plane as a control and include both tilt directions, alongside the focused image-edge tests. This can stay part of the immediate rounding fix without depending on the shared-helper refactor discussed above.

  5. kvnloo commented on Sep 24, 2026

    @kvnloo

    Follow-up with validation of the proposed nearest-pixel change.

    I tested the two-line roundf() change against the unchanged implementation using identical inputs and source-built Open3D artifacts.

    The focused pixel-selection regression gives:

    • current implementation: 12 / 20 cases pass;
    • candidate: 20 / 20 pass.

    I also wanted to check that this improves the reconstructed surface rather than merely changing which pixel is selected. Using analytic planes and fixed world-space measurement rays, all 24 tilted-plane conditions in the larger A/B improved in both RMS error and absolute mean bias. Fixed-ray RMS decreased by 62.2%–85.7% (median 78.6%), while the flat controls remained below 0.001 mm RMS.

    I then reduced that experiment to a much smaller regression: one flat control plus four planes tilted in opposite x/y directions. With the same inputs and measurement locations:

    • the flat control passes before and after;
    • all four tilted cases fail on the current implementation;
    • all four pass with the candidate;
    • measurement coverage remains 100%.

    I don't think the existing reconstruction point/triangle counts should simply be refreshed to make CI green. Those counts do change with the corrected sampling, but the more useful invariant here seems to be whether the reconstructed geometry matches the known surface. I'd prefer keeping the count-expectation question separate and reviewable.

    Candidate + detailed validation record:
    kvnloo#2

    Regression-only control:
    kvnloo#1

    I haven't validated CUDA/SYCL behavior yet, so I'm treating this as CPU evidence rather than a complete backend validation.

    AI-assisted implementation, experiment design, and validation review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions