示例#1
0
        public void SingleSubGrid_AtOrigin(ConvolutionMaskSize contextSize)
        {
            const float ELEVATION = 10.0f;

            var tree    = DataSmoothingTestUtilities.ConstructSingleSubGridElevationSubGridTreeAtOrigin(ELEVATION);
            var subGrid = tree.LocateSubGridContaining(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.SubGridTreeLevels) as GenericLeafSubGrid <float>;

            subGrid.Should().NotBeNull();

            var result = DataSmoothingTestUtilities.ConstructElevationSubGrid(CellPassConsts.NullHeight);

            result.Should().NotBeNull();

            var accumulator = new ConvolutionAccumulator_Float(CellPassConsts.NullHeight, contextSize);
            var filter      = new MeanFilter <float>(accumulator, contextSize, NullInfillMode.NoInfill);
            var smoother    = new ConvolutionTools <float>();

            smoother.Convolve(subGrid, result, filter);

            // All cell values should remain mostly unchanged due to non-null values around perimeter of subgrid in smoothing context
            // Check all acquired values in the single subgrid are the same elevation, except for the perimeter values which
            // will be 2/3 * Elevation due to null values. Some corner vales will have 0.44444 * ElEVATION for same reason
            SubGridUtilities.SubGridDimensionalIterator((x, y) =>
            {
                var ok = Math.Abs(result.Items[x, y] = ELEVATION) < 0.0001 ||
                         Math.Abs(result.Items[x, y] = (2 / 3) * ELEVATION) < 0.0001 ||
                         Math.Abs(result.Items[x, y] = 0.44444f * ELEVATION) < 0.0001;
                ok.Should().BeTrue();
            });
        }
示例#2
0
        private GenericSubGridTree <float, GenericLeafSubGrid_Float> ConstructSingleSubGridElevationSubGridTreeAtOrigin(float elevation)
        {
            var tree = new GenericSubGridTree <float, GenericLeafSubGrid_Float>();

            var subGrid = tree.ConstructPathToCell(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                   SubGridPathConstructionType.CreateLeaf) as GenericLeafSubGrid <float>;

            DataSmoothingTestUtilities.ConstructElevationSubGrid(subGrid, elevation);

            return(tree);
        }