Filtering

The class Easy3D contains a number of static methods to filter a ZMap (or a depth map):
RemoveNoise
The method RemoveNoise removes outliers from a depth map or a ZMap.
● | It takes a depth map or a ZMap as input and generates a depth map or a ZMap respectively. |
The invalid points are not taken into account.
● | It is based on a square moving window. The size of the window is (2 x halfKernelSize + 1) where halfKernelSize is a parameter of this method. |
● | The parameter threshold is scaled in function of the precision contained in the depth map and/or in function of the vertical Z scale contained in the ZMap. |
● | There are 3 variations of this filter, depending on the parameter method: |
□ | method = E3DNoiseRemovalMethod_AbsoluteDifferenceFromMean: it removes a point when it deviates from the average in the neighborhood, including itself. The threshold is an absolute difference. |
□ | method = E3DNoiseRemovalMethod_RelativeDifferenceFromMean: it removes a point when it deviates from the average in the neighborhood, including itself. The threshold is a multiple of the standard deviation. |
□ | method = E3DNoiseRemovalMethod_HighStandardDeviation: it removes a point when the standard deviation in the neighborhood, including itself, is higher than a defined threshold. |
ComputeAverageMap
The method ComputeAverageMap is a low-pass filter.
● | It takes a depth map or a ZMap as input and generates a depth map or a ZMap respectively. |
The invalid points are not taken into account.
● | It is based on a square moving window. The size of the window is (2 x halfKernelSize + 1) where halfKernelSize is a parameter of this method. |
ComputeStandardDeviationMap
The method ComputeStandardDeviationMap computes the standard deviation image.
● | It takes a depth map or a ZMap as input and generates an image. |
● | In the generated image, a pixel with the value 0 is either "invalid" or has a zero standard deviation. |
Example 1: Removing points showing a high standard deviation
The code below removes pixels with a standard deviation higher than a defined threshold.
// ___Load the zmap data___
EZMap16 zmap;
// (...)
// ___(optional) for display, calculate the standard deviation image___
EImageBW16 imgStd;
imgStd.SetSize(&(zmap.AsEImage()));
Easy3D::ComputeStandardDeviationMap(zmap, imgStd, 3, 0.0);
imgStd.SaveImage(path + "\\" + "stdImg.png");
// ___Calulate the filtered Z map. The new Z map is called ZmapF___
// size of the filter window 7x7 pixels, threshold = 30.0
EZMap16 zmapF;
zmapF.SetSize(zmap);
Easy3D::RemoveNoise(zmap, zmapF, E3DNoiseRemovalMethod_HighStandardDeviation, 3, 30.0, 0.0);
zmapF.SaveImage(path + "\\" + "zmapF.png", EImageFileType_Png);
Example 2: Low pass filter a ZMap, then remove points showing a deviation larger than a defined threshold
The code below first applies an averaging filter, then removes from the result the pixels showing a deviation from the neighborhood larger than the defined threshold.
// ___Load the zmap data___
EZMap16 zmap;
// (...)
// ___Calulate the filtered Z map. The new Z map is called ZmapF2 ___
// size of the filter window 7x7 pixels, threshold = 30.0
EZMap16 zmapF2;
zmapF2.SetSize(zmap);
Easy3D::ComputeAverageMap(zmap, zmapF2, 3, 0.2);
zmapF2.SaveImage(path + "\\" + "zmapF2.png", EImageFileType_Png);
// ___Calulate the filtered Z map. From Z_map_F2, calculate Z_mapF3 ___
// size of the filter window 31x31 pixels, threshold = 20.0
EZMap16 zmapF3;
zmapF3.SetSize(zmap);
Easy3D::RemoveNoise(zmapF2, zmapF3, E3DNoiseRemovalMethod_AbsoluteDifferenceFromMean,
15, 20.0, 0.2);
zmapF3.SaveImage(path + "\\" + "zmapF3.png", EImageFileType_Png);