MIL_ID StatContext3dimId,  //in 
MIL_ID ContainerOrImageBufId,  //in 
MIL_ID StatResult3dimId,  //in 
MIL_INT64 ControlFlag  //in 
This function calculates a variety of statistics for the 3D points in a point cloud or for the realworld coordinates that correspond to pixels in a depth map. The specified statistics 3D image processing context establishes which statistics to calculate and how to calculate them. If you need to calculate one type of statistic and use default settings, you can use a predefined context; otherwise, use M3dimAlloc() to set up a custom context that you can control using M3dimControl(). For example, you can enable bounding box statistics calculations (M_BOUNDING_BOX), and have the algorithm compute the axisaligned box that contains most of the points but rejects outliers ( M_BOUNDING_BOX_ALGORITHM set to M_ROBUST). Note that, if you use the default M_STAT_CONTEXT_BOUNDING_BOX context, M3dimStat() computes the bounding box of all valid points. Results are stored in the specified 3D statistics result buffer.
After calling M3dimStat(), you can obtain the statistics from the result buffer using M3dimGetResult().
Note that there must be a sufficient number of valid points in the source point cloud container or image buffer for the statistics to be calculated, otherwise the result will be 0. This means that there must be at least 2 valid points for M_STAT_CONTEXT_DISTANCE_TO_NEAREST_NEIGHBOR calculations, and at least 1 valid point for all other statistics types.
Specifies a previously allocated statistics 3D image processing context (used to evaluate multiple statistical calculations), or a predefined statistics 3D image processing context (used to evaluate a single statistical calculation).
Set this parameter to one of the following:
For specifying the statistics context


Value  Description  
M_STAT_CONTEXT_BOUNDING_BOX 
Specifies a predefined statistics 3D image processing context with the M_BOUNDING_BOX control type (M3dimControl()) set to M_ENABLE. 

M_STAT_CONTEXT_CENTROID 
Specifies a predefined statistics 3D image processing context with the M_CENTROID control type (M3dimControl()) set to M_ENABLE. 

M_STAT_CONTEXT_DISTANCE_TO_NEAREST_NEIGHBOR 
Specifies a predefined statistics 3D image processing context with the M_DISTANCE_TO_NEAREST_NEIGHBOR control type (M3dimControl()) set to M_ENABLE. 

M_STAT_CONTEXT_NUMBER_OF_POINTS 
Specifies a predefined statistics 3D image processing context with the M_NUMBER_OF_POINTS control type (M3dimControl()) set to M_ENABLE. 

MIL statistics 3D image processing
context identifier 
Specifies the identifier of a statistics 3D image processing context, previously allocated using M3dimAlloc() with M_STATISTICS_CONTEXT. 
Specifies the identifier of the source container containing a 3Dprocessable point cloud, or specifies the identifier of the source depth map image buffer.
The container must be 3Dprocessable (that is, if you call MbufInquireContainer() with M_3D_PROCESSABLE, the function returns M_PROCESSABLE), and must have been previously allocated using MbufAllocContainer() with M_PROC. The container must have at least the 2 components M_COMPONENT_RANGE and M_COMPONENT_CONFIDENCE.
The source image buffer must be a 1band, 8, 16, or 32bit unsigned buffer, and must be fully corrected (that is, if you call McalInquire() with M_DEPTH_MAP, the function returns M_TRUE). The source image buffer can have a region of interest (ROI) associated with it, but it must be a raster region. Using an image buffer with a nonraster type of ROI will cause an error.
Specifies the identifier of the statistics 3D image processing result buffer. The buffer must have been allocated using M3dimAllocResult() with M_STATISTICS_RESULT.
Header  Include mil.h. 
Library  Use mil.lib; mil3dim.lib. 
DLL  Requires mil.dll; mil3dim.dll. 