Using EFilters to Remove the Noise on a ZMap Based on the Derivation from Neighborhood Code Snippet¶
The code below first applies a low pass filter to a ZMap. It then removes from the result the pixels showing a deviation from the neighborhood larger than the defined threshold.
C++¶
#include <eVision/Easy3D/EStatistics.h>
#include <eVision/Easy3D/EFilters.h>
using namespace eVision::Easy3D;
// Load the ZMap data
EZMap16 zmap;
zmap.Load("");
// Compute the filtered ZMap. The new ZMap is called averagedZMap
// The size of the kernel is 7x7, the threshold is 30.0
EZMap16 averagedZMap;
averagedZMap.SetSize(zmap);
EStatistics::ComputeAverageMap(zmap, averagedZMap, 3, 0.2f);
// Compute the filtered ZMap. From averagedZMap, compute filteredZMap
// The size of the kernel is 31x31, the threshold is 20.0
EZMap16 filteredZMap;
filteredZMap.SetSize(zmap);
EFilters::RemoveNoise(averagedZMap, filteredZMap, ENoiseRemovalMethod_AbsoluteDifferenceFromMean, 15, 20.0, 0.2f);
C#¶
using eVision.Easy3D;
// Load the ZMap data
EZMap16 zmap = new EZMap16();
zmap.Load("...");
// Compute the filtered ZMap. The new ZMap is called averagedZMap
// The size of the kernel is 7x7, the threshold is 30.0
EZMap16 averagedZMap = new EZMap16();
averagedZMap.SetSize(zmap);
EStatistics.ComputeAverageMap(zmap, averagedZMap, 3, 0.2F);
// Compute the filtered ZMap. From averagedZMap, compute filteredZMap
// The size of the kernel is 31x31, the threshold is 20.0
EZMap16 filteredZMap = new EZMap16();
filteredZMap.SetSize(zmap);
EFilters.RemoveNoise(averagedZMap, filteredZMap, ENoiseRemovalMethod.AbsoluteDifferenceFromMean, 15, 20.0F, 0.2F);
Python¶
from eVision import Easy3D
# Load the ZMap data
zmap = Easy3D.EZMap16()
zmap.Load("...")
# Compute the filtered ZMap. The ZMap is called averaged_zmap
# The size of the kernel is 7x7, the threshold is 30.0
averaged_zmap = Easy3D.EZMap16()
averaged_zmap.SetSize(zmap)
Easy3D.EStatistics.ComputeAverageMap(zmap, averaged_zmap, 3, 0.2)
# Compute the filtered ZMap. From averaged_zmap, compute filtered_zmap
# The size of the kernel is 31x31, the threshold is 20.0
filtered_zmap = Easy3D.EZMap16()
filtered_zmap.SetSize(zmap)
Easy3D.EFilters.RemoveNoise(averaged_zmap, filtered_zmap, Easy3D.ENoiseRemovalMethod.AbsoluteDifferenceFromMean, 15, 20., 0.2)