A segmented image gives you a count of selected samples, not automatically a physical volume. You also need the physical dimensions represented by each sample and a clear definition of what the segmentation contains. This workflow is for engineers converting masks, image stacks, or reconstructed grids into volume measurements. You will establish the axis spacing, calculate each voxel's contribution, and check whether the available data supports a volume measurement at all.
Decide whether your data represents area or volume
A pixel in a calibrated flat image represents an area. A voxel in a calibrated volumetric grid represents a volume. Drawing a contour selects samples; it does not supply their physical dimensions or reveal the object's hidden surfaces.
Before calculating, identify which dataset you have:
| Dataset | What a selected sample represents | What you can calculate |
|---|---|---|
| Calibrated planar image | An area element on the calibrated plane | Area; volume only with a justified thickness assumption |
| Regular volumetric image stack | A volume element with known axis spacing | Segmented volume by counting occupied voxels |
| Calibrated height raster | Surface height above a reference plane | Volume by integrating height over physical grid cells |
| Perspective depth image | A surface observation along a viewing ray | Surface geometry; volume requires additional geometry and closure |
| Unstructured point cloud | A sampled surface location | Not volume from point count alone |
For a flat image, start with calibrated planar distance measurement. For reconstructed occupancy data, the closest foundation is storing point cloud data in a voxel grid. A voxelized surface and a filled solid are different representations, even when their grids have identical spacing.
Calculate volume in six steps
-
Confirm what the mask includes. Determine whether the selected region represents material, a cavity, a surface shell, or an assumed extrusion. For a stack, check that the mask covers the intended slices rather than only the displayed slice.
-
Read the spacing for every spatial axis. Record
sx,sy, andszfrom calibrated metadata or a validated reconstruction configuration. Distinguish physical spacing from array dimensions, pixel indices, image magnification, and display zoom. If a metadata record labels two entries as Y, resolve that ambiguity before assuming one means X. -
Put all spacing values in the same length unit. Convert millimeters to centimeters by dividing by 10. Convert micrometers to centimeters by dividing by 10,000. Do this before multiplying the dimensions. Three centimeter values produce cubic centimeters; mixed units do not.
-
Count the selected voxels. For a binary mask, count nonzero entries rather than summing their stored values. A mask encoded with 255 for foreground still represents one selected sample per foreground location. For a labeled image, count only the required label.
-
Multiply the count by the voxel volume. Use the formula below for a uniformly spaced, orthogonal grid. Keep enough numerical precision during calculation, then round the reported result to match the measurement uncertainty.
-
Record the assumptions with the answer. Save the count, spacing, units, grid definition, segmentation version, and treatment of cavities. Report an assumed extrusion as an estimate, not as a fully observed solid.
These equations assume that every counted voxel contributes its full cell volume. Fractional occupancy requires weights between zero and one, not a simple foreground count.
Work through a calibrated example
Assume verified metadata gives the following spacing for a regular grid:
- X spacing: 0.09 cm.
- Y spacing: 0.09 cm.
- Z spacing: 0.18 cm.
The voxel is rectangular rather than cubic. Its Z dimension is twice either lateral dimension, which matters when inspecting boundaries and small features.
If those selected samples belong to one image rather than a volume stack, the same arithmetic describes an extrusion through an assumed thickness. It does not prove that the actual object occupies that entire thickness.
For a stack, count the selected samples across all included slices. If the total is already 2,500, do not multiply by the number of slices again. Alternatively, calculate each slice's contribution and sum them; both approaches agree when spacing is constant.
A useful distinction is area versus center-to-center distance. Ten selected pixels occupy ten pixel cells. The distance between the first and last pixel centers spans only nine intervals. Use the cell count for area and volume, not a coordinate-span formula.
Handle slice spacing and depth maps correctly
For a regularly sampled volume, Z spacing usually describes the distance between adjacent slice positions. Acquisition slice thickness describes the measurement's support along that axis. These quantities can differ when slices overlap or have gaps.
Do not automatically substitute acquisition thickness for reconstruction spacing. Establish which physical cells the reconstructed volume assigns to its samples. Overlapping slices must not count the same physical region repeatedly, while gaps introduce uncertainty about unobserved material.
For unequal slice positions, assign a documented integration thickness to each slice, based on the reconstruction method and boundary convention:
A height raster needs a different calculation. If heights are measured above a reference plane on a uniformly spaced physical XY grid, integrate height over the cells:
This expression does not apply directly to raw perspective depth pixels. Their projected area changes with geometry, and depth may describe axial distance rather than height above your chosen plane. The inline volume measurement workflow explains the broader measurement setup, including the reference surface and volume boundary.
Missing depth is not zero height. Exclude invalid observations and handle the resulting unknown region explicitly. Use the checks in diagnosing invalid deprojected points before integrating a depth-derived surface.
Choose acquisition hardware around the representation
Choose hardware after deciding whether you need a flat area, a height surface, or a closed volumetric representation. Browse 3D sensors for depth acquisition and use the camera finder to narrow the available acquisition approaches.
The MIS-DP3850-01P is a laser profiler. For a moving-part measurement, confirm how profiles receive their position along the direction of travel. Encoder scaling and motion synchronization affect reconstructed spacing; the scan-spacing troubleshooting guide addresses that separate calibration problem.
- Type
- Laser profiler
The MV-DPS200P-02 is a projected structured-light camera. Evaluate whether the acquired views expose the boundaries needed for your intended volume calculation. A visible surface alone does not establish the object's hidden geometry.
- Type
- Stereo / structured light
Neither acquisition approach removes the need to define occupancy, calibration, and boundary handling in software. Confirm the manufacturer's documented data format and calibration output before selecting a processing workflow.
Area scan cameras remain useful when the inspection requires only planar area or an independently justified constant thickness. They do not supply depth merely because the image has many pixels. Start the camera configuration workflow after establishing the required measurement representation.
Verify the arithmetic and estimate uncertainty
First, test the software with a synthetic rectangular mask. A block containing 10 samples along X, 20 along Y, and 5 along Z contains 1,000 voxels.
Using the example spacing, its physical dimensions are 0.9 cm, 1.8 cm, and 0.9 cm. The two independent calculations should agree:
This verifies implementation and units, not real-world accuracy. Next, measure a reference object with independently known geometry under the intended acquisition conditions. Repeat the measurement after repositioning it to expose location-dependent calibration or segmentation errors.
Spacing errors multiply across the axes. For small errors, an approximate conservative relative error bound is:
This is a first-order bound, not a statistical confidence interval. If each axis spacing has a 1% error bound, calibration alone can contribute approximately 3% volume error. Segmentation and missing-data errors require separate allowances.
Inspect sensitivity to reasonable segmentation changes. A thin object can lose a large fraction of its measured volume when its boundary moves by one voxel. Report that sensitivity rather than implying that many displayed decimal places establish accuracy.
Recognize when voxel counting is the wrong answer
Counting occupied surface voxels measures the thickness of the represented shell, not necessarily the enclosed solid. A point-cloud-to-grid conversion can therefore produce a stable count while still answering the wrong measurement question.
Likewise, filling every enclosed cavity changes the meaning of volume. Material volume excludes voids; envelope volume may include them. Define the required quantity before applying hole filling or morphological operations.
Resampling also needs care. After changing grid spacing, use the new physical voxel dimensions. Label interpolation can alter boundaries, so compare physical volume before and after resampling rather than expecting the foreground count to remain unchanged.
Finally, the spacing product assumes orthogonal grid axes. For a general affine index-to-physical transformation with shear, cell volume comes from the absolute determinant of its spatial transformation matrix. Use the documented geometry rather than multiplying coordinate increments that are not perpendicular dimensions.
Check the measurement before ordering
- Define the quantity: material, cavity, envelope, or extrusion volume. This determines the required boundaries.
- Confirm all axes: identify X, Y, and Z spacing, their units, and their relationship to array order.
- Verify coverage: decide how hidden surfaces, cavities, and invalid samples will be handled.
- Check reconstruction spacing: distinguish sampling pitch from acquisition thickness and display scaling.
- Validate the implementation: use a synthetic block, then a physical reference with known geometry.
- Set an acceptance limit: include calibration, segmentation, repeatability, and missing-data contributions.
- Retain traceability: save the mask and metadata needed to reproduce the reported volume.
If the acquisition or metadata remains uncertain, bring a sample dataset and your required volume tolerance to applications support. Establishing the physical grid and measurement boundary before choosing hardware prevents a pixel-count calculation from becoming an unsupported volume claim.
Questions
How do I convert a segmented voxel count into cubic centimeters?
Multiply the number of selected voxels by the physical X, Y, and Z spacing, with all spacing values expressed in the same length unit. This gives volume for a uniformly spaced orthogonal grid. Confirm that the segmentation represents occupied material rather than only sampled surface locations.
Can I calculate volume from a contour in a single image?
A contour provides an image region, which can become a physical area after planar calibration. Volume additionally requires measured depth, a calibrated image stack, or a justified thickness assumption. Multiplying by an assumed thickness gives an extrusion estimate, not proof of the object's actual three-dimensional shape.
Is slice thickness always the correct Z spacing?
No. Slice thickness describes the acquisition's depth support, while slice spacing describes separation between sample positions. They can differ with overlapping or separated slices. Use the physical integration cells defined by the reconstruction, and document how overlaps, gaps, and end slices contribute to the result.
Why does my calculated volume change after resampling?
Resampling changes the number and size of grid cells, while interpolation can also move the segmented boundary. Recalculate using the output grid's physical spacing and compare physical volumes before and after processing. A changed foreground count is expected; a large unexplained physical-volume change needs investigation.
Does counting occupied point-cloud voxels give solid volume?
Not by itself. An occupied voxel may contain only a small surface observation, so counting such cells measures the sampled shell representation. Solid volume requires a defensible occupancy model, a closed surface reconstruction, or another integration method with clearly defined boundaries and treatment of unseen regions.

