Most 3D sensors make use of one or more area scan cameras, so that the resulting 3D coordinates are usually distributed on a (pseudo-)regular grid. We can benefit from this to speed up 3D data processing. Here we will demonstrate this approach for fast outlier removal.
Let’s consider the 3D data in figure 1: we ought to remove the outliers as shown in figure 2. Performing this directly on the 3D object model might be time consuming. But outliers consist in a large deviation from the expected z-coordinates while the x- and y-coordinates are virtually undisturbed. Therefore, we can obviously remove outliers by only processing the z-coordinates, thus simplifying complex 3D processing to a fast 2D processing task.
First, we make a full copy of the 3D object model to process, including all available extended attributes (i.e., set ’Attributes’ to ’all’):
copy_object_model_3d (ObjectModel3D, ‘all’, ObjectModel3DCleaned)
Then, we must ensure that xyz-mapping information is available and if so, we separate the x-, y-, and z-coordinates into 3 images (see fig. 3):
get_object_model_3d_params (ObjectModel3DCleaned, ‘has_xyz_mapping’, HasXYZMapping)
if (HasXYZMapping = ‘true’)
imagesobject_model_3d_to_xyz (ImageX, ImageY, ImageZ, ObjectModel3DCleaned,’from_xyz_map’, [],[])
Now, we can detect outliers in the original z-image with a usual 2D processing method. We compare the original z-coordinate image with its median-filtered result of them by using dynamic thresholding. Strong deviations above the value of MaxDist are considered to be outliers and the corresponding original z-coordinates are replaced by the respective values of the median filtered image (See fig. 3, 4).
MedianRadius := 15
MaxDist := 10.0
get_domain (ImageZ, Domain)
expand_domain_gray (ImageZ, ExpandedZImage, MedianRadius+2)
median_image (ExpandedZImage, ImageMedian, ‘circle’, MedianRadius, ‘mirrored’)
dyn_threshold (ImageZ, ImageMedian, RegionDynThresh, MaxDist, ‘not_equal’)
intersection (Domain, RegionDynThresh, RegionIntersection)
reduce_domain (ImageMedian, RegionIntersection, ImageReducedZ)
overpaint_gray (ImageZ, ImageReducedZ)
Finally, we move the corrected z-coordinates into the 3D object model and obtain 3D data free of
outliers (see fig. 5). Note that only the z-coordinate of outliers have been modified, all other points keep their original coordinates!
get_object_model_3d_params (ObjectModel3DCleaned, ‘mapping_row’, MappingRow)
get_object_model_3d_params (ObjectModel3DCleaned, ‘mapping_col’, MappingCol)
get_grayval (ImageZ, MappingRow, MappingCol, NewPointCoordsZ)
set_object_model_3d_attrib_mod (ObjectModel3DCleaned, ‘point_coord_z’, [], NewPointCoordsZ)
In conclusion, bear in mind that you can take advantage of xyz-mapping information to apply 2D image processing algorithms on 3D data and thus speed up your application. Further possible applications: reduce the amount of 3D points by using zoom_image_factor, fill small holes with harmonic_interpolation or smooth the 3D data with smooth_image.