3D visionHow-to

Voxel grid comparison: align scans to identify new coverage

Build a voxel grid comparison with shared coordinates, origin, and cell size, then distinguish new scan coverage from noise and physical changes.

LumaSpec Vision9 min read Share on LinkedIn

On this page 9 sections
  1. 01Define what the comparison should report
  2. 02Establish the acquisition and calibration inputs
  3. 03Transform both clouds into one coordinate frame
  4. 04Assign voxel indices from one fixed origin
  5. 05Compare occupied keys, not point-array positions
  6. 06Account for uncertainty and visibility
  7. 07Verify with repeated and controlled acquisitions
  8. 08Check the implementation before ordering or deployment
  9. 09Questions

A second depth scan often reveals surfaces hidden from the first viewpoint. Finding that additional coverage requires more than subtracting point coordinates: both scans must describe the same space, and both voxel grids must use identical indexing rules. This procedure is for engineers combining depth views for inspection, mapping, or scan planning. You will build a shared occupancy grid, compare integer voxel keys, and separate newly observed coverage from registration artifacts and possible physical changes.

Define what the comparison should report

For surface point clouds, an occupied voxel means that at least one accepted surface sample falls inside that cell. It does not mean the entire cell contains solid material. Likewise, a voxel without samples is not necessarily empty: it might be hidden, outside the field of view, or missing valid depth.

Let A contain the occupied voxel indices from the reference scan and B contain those from the second scan. Then B minus A identifies cells sampled only in the second scan. Call these candidate new coverage, not confirmed scene changes.

Use this processing order:

  1. Establish a common coordinate frame and transform both point clouds into it.
  2. Filter invalid measurements and select the same physical region of interest.
  3. Convert points to voxel keys using one origin and voxel size.
  4. Compare occupied-key sets and retain their supporting measurements.
  5. Evaluate boundary sensitivity, registration uncertainty, and visibility.
  6. Validate the result against repeated scans and controlled changes.

If your input begins with image detections rather than complete clouds, first check mapping image pixels into depth coordinates. Incorrect pixel correspondence creates geometric errors that voxelization cannot repair.

Establish the acquisition and calibration inputs

You need valid depth measurements, their coordinate units, camera calibration, and a transform for each acquisition pose. Record acquisition identifiers and timestamps alongside the clouds. Retain confidence values and source pixel coordinates when the acquisition system provides them.

For hardware selection, start with 3D sensors and narrow the measurement method through the camera finder. A depth device must suit the surface, working range, motion, and required measurement uncertainty; voxel processing does not compensate for unsuitable acquisition geometry.

The MV-DLS300P-04 is cataloged as a laser galvanometer stereo camera. Confirm its output formats, calibration access, and acquisition requirements before choosing it for this workflow.

3D sensorsHikrobot MV-DLS300P-04 Laser galvanometer stereo cameraMV-DLS300P-04
Type
Stereo / structured light
$16,579.00 · quotedView and quote

The MV-DPS200P-02 is cataloged as a projected structured-light 3D camera. Assess its documented interfaces against the same processing requirements rather than assuming interchangeable outputs.

3D sensorsHikrobot MV-DPS200P-02 Projected structured-light 3D cameraMV-DPS200P-02
Type
Stereo / structured light
$8,829.00 · quotedView and quote

An additional intensity camera may help observe calibration targets or attach appearance information. However, area scan cameras do not provide metric depth merely because their images are sharp. Any separate image stream needs its own calibrated relationship to the depth frame.

Before comparing clouds, inspect missing measurements using the checks in stereo point-cloud visualization. Otherwise, a change in valid-depth coverage can look like newly discovered geometry.

Transform both clouds into one coordinate frame

Choose a reference frame that remains meaningful across acquisitions. This might be the first camera pose, a fixed calibration target, or a stationary fixture. Write down the axis directions, units, and transform direction explicitly.

Using column vectors, define T_W_C as the transform that maps camera-frame coordinates into the common frame:

p_W = R_W_C × p_C + t_W_C [p_W; 1] = T_W_C × [p_C; 1]

Apply the appropriate transform to every accepted point from each scan. If the first camera defines the common frame, its transform is the identity. The second cloud still needs the transform mapping its camera frame into that first frame.

For fixed cameras, estimate their relative pose through a suitable calibration procedure. For a moving camera, use a measured pose or validated registration method. Registration from overlapping geometry can work, but flat surfaces, repeated shapes, and limited overlap can leave motion poorly constrained.

Do not confuse camera intrinsics with extrinsics. Intrinsics describe image projection; extrinsics describe the relationship between coordinate frames. If depth and texture images use different projection models, check intrinsic parameters for depth and texture images before transferring coordinates.

Verify the transform on several shared features, not just one point. A transform that aligns one location can still contain a rotation error elsewhere. For moving scenes, also address the timing issues described in multi-camera point-cloud synchronization.

Assign voxel indices from one fixed origin

Define the grid in the common coordinate frame. Both scans must use the same origin o, cubic voxel edge length h, axis order, and rounding convention.

For a transformed point p, compute its integer key as follows:

k_x = floor((p_x - o_x) / h) k_y = floor((p_y - o_y) / h) k_z = floor((p_z - o_z) / h) voxel key = (k_x, k_y, k_z)

Use mathematical floor, not truncation toward zero. With an origin of zero and a voxel size of 10 mm, a coordinate of -1 mm belongs to index -1, not index 0.

A common implementation mistake is allowing each cloud to choose its grid origin from its own minimum coordinate. The resulting index tuples then refer to different physical cells, even when the voxel sizes match. Persist the origin and voxel size as comparison metadata rather than recalculating them independently.

Choose an initial cell size from measured uncertainty and the smallest coverage feature you need to distinguish. For example, if repeated scans scatter across several millimeters, a 1 mm grid will produce many unstable occupancy differences. A 10 mm grid may be more repeatable, but it cannot represent narrow features reliably.

There is no universal multiplier that makes voxel size correct. Test several sizes against repeated observations and known features. Apply the same cropping bounds, confidence filters, and depth-unit conversion before generating either set.

Compare occupied keys, not point-array positions

Build a set of integer keys for each scan. Point ordering and point count do not need to match. Multiple points inside one cell produce one occupied key, although you should retain their support counts for later filtering.

candidate new coverage = B minus A shared occupancy = A intersect B reference-only coverage = A minus B

The following pseudocode illustrates the comparison without depending on a particular processing library:

A = occupied_keys(reference_points, origin, voxel_size)
B = occupied_keys(second_points, origin, voxel_size)

new_keys = B.difference(A)
shared_keys = B.intersection(A)
reference_only_keys = A.difference(B)

Reference-only coverage is not evidence of removal. The second viewpoint might simply fail to see those surfaces.

For a worked example, use millimeters throughout, with origin (0, 0, 0) and h = 10 mm. Suppose a second-camera point is (-80, 27, 103) and its transform has identity rotation with translation (100, 0, 0):

p_W = (-80 + 100, 27 + 0, 103 + 0) = (20, 27, 103) mm key = (floor(20 / 10), floor(27 / 10), floor(103 / 10)) = (2, 2, 10)

Now suppose the occupied sets are:

A = {(2, 2, 10), (3, 2, 10)}
B = {(2, 2, 10), (3, 3, 10), (8, 2, 10)}

B minus A = {(3, 3, 10), (8, 2, 10)}

Two cells are newly occupied under exact matching. That is a valid indexing result, but it is not yet a reliable interpretation of the scene.

Account for uncertainty and visibility

Even a stationary surface can cross a voxel boundary because of depth noise or pose error. Angular error becomes especially noticeable farther from the frame origin. For a small angular error, the displacement estimate is:

lateral displacement ≈ distance × angular error in radians 1,000 mm × (0.5 × pi / 180) ≈ 8.7 mm

That displacement is comparable to the example cell size. Measure alignment residuals across the complete working region, not only near the calibration target center.

One screening method accepts a second-scan cell as already covered when a reference cell exists within a small index neighborhood. A radius of one cell under a maximum-axis-distance rule includes the cell itself and its 26 immediate neighbors.

In the worked example, (3, 3, 10) neighbors (3, 2, 10), so this rule suppresses it. The cell (8, 2, 10) remains a candidate. However, neighborhood suppression can also erase genuine adjacent coverage. Treat it as a declared tolerance policy, not a correction to the measurements.

Comparison rule Useful when Main limitation
Exact occupied-key difference Registration is stable relative to cell size Sensitive to cell boundaries
Neighbor-tolerant difference Small residual errors dominate the result Can hide nearby new surfaces
Metric distance to reference samples A physical distance threshold is required Depends on sampling density
Occupancy with visibility evidence Physical change detection is the goal Requires ray geometry and uncertainty handling

A surface hidden behind another surface in the first view can appear legitimately in the second. To investigate physical additions, distinguish previously observed free space from unknown space. Trace valid measurement rays using their acquisition poses, while accounting for depth uncertainty and surface boundaries. Missing depth alone provides no reliable free-space evidence.

Verify with repeated and controlled acquisitions

Begin with a rigid, stationary scene. Capture repeated observations from the same pose, then from different poses with substantial overlap. Save the raw clouds, transforms, grid metadata, and comparison masks so each stage can be reviewed separately.

Measure at least these quantities:

  • Candidate-cell count within the expected overlapping region.
  • Candidate-cell count outside that overlap.
  • Shared-feature alignment residuals across the working volume.
  • Support counts and connected-group sizes for candidate cells.
  • Sensitivity to voxel size and neighborhood tolerance.

For example, if the second scan occupies 20,000 cells and 600 appear new inside known overlap, the candidate fraction is 600 / 20,000 = 3%. This is a diagnostic metric, not an automatic acceptance limit. Compare it with repeated-scan variation and the application's allowable errors.

Then introduce a known surface or expose a previously hidden region. Confirm that the result appears in the expected location without widespread false candidates elsewhere. Require repeatable observations or sufficient local support when isolated measurements would create unacceptable false reports.

When surfaces produce inconsistent depth, address acquisition quality first. The guide to lighting stereo depth on dark surfaces explains why additional illumination does not always translate directly into reliable geometry.

Check the implementation before ordering or deployment

Use this checklist before treating the result as an engineering measurement:

  • Frame contract: Every transform has a documented direction, unit, axis convention, and acquisition association.
  • Grid contract: Both scans share one origin, voxel size, boundary convention, and comparison region.
  • Measurement validity: Invalid depth and unsuitable confidence values are rejected consistently.
  • Registration evidence: Residuals are measured throughout the working region, including difficult geometry.
  • Coverage definition: Reports distinguish sampled surfaces, observed free space, and unknown regions.
  • Repeatability: Stationary-scene tests establish the normal candidate rate before change thresholds are selected.
  • Hardware fit: Confirm output access, calibration procedures, surface compatibility, and timing requirements in the documented product information.

For accumulated coverage, compare each new scan against the union of accepted earlier occupancy, rather than only its immediate predecessor. Keep pose provenance: if earlier poses change during later registration, their voxel assignments must be recomputed.

Use the camera configurator to organize the acquisition requirements, or contact the applications team with sample clouds, working geometry, and the smallest coverage feature you need to distinguish.

Questions

Can I subtract two voxel grids directly?

Transforming the scans into one frame is necessary, but grid construction must also match. Use the same voxel origin, edge length, axis convention, and floor operation. Otherwise, identical index values can describe different locations, or the same surface can receive different keys.

How should I choose the voxel size?

Choose it through repeatability testing and the smallest feature you need to distinguish. Cells much smaller than measurement uncertainty tend to produce unstable differences. Larger cells reduce spatial detail and can merge separate surfaces. Compare several sizes using stationary scans and known additional coverage.

Why does an unchanged object produce new occupied voxels?

A changed viewpoint reveals previously hidden surfaces and changes sampling density. Depth noise, imperfect pose estimates, and points near cell boundaries also create occupancy differences. Validate registration and visibility before deciding whether a candidate represents additional coverage or a physical addition.

Can this work with fixed cameras and a moving camera?

Yes, when a validated transform relates every acquisition pose to a common reference. A moving camera additionally needs reliable pose estimation and correct association between measurements and poses. Fixed cameras need stable mounting and calibration; neither arrangement removes the need to check overlap and uncertainty.

Does an unoccupied voxel mean the space is clear?

No. A missing sample can indicate occlusion, invalid depth, or a location outside the observed region. Establishing free space requires valid viewing-ray evidence and suitable uncertainty handling. Surface occupancy subtraction alone cannot certify clearance or replace a machine safety function.