示例#1
0
        public void Smooth()
        {
            const float  elevation = 10.0f;
            const double oneNinth  = 1d / 9d;

            var source        = DataSmoothingTestUtilities.ConstructSingleSubGridElevationSubGridTreeAtOrigin(elevation);
            var sourceSubGrid = source.LocateSubGridContaining(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.SubGridTreeLevels) as GenericLeafSubGrid <float>;

            sourceSubGrid.Should().NotBeNull();

            var tools  = new ConvolutionTools <float>();
            var accum  = new ConvolutionAccumulator_Float(CellPassConsts.NullHeight, ConvolutionMaskSize.Mask3X3);
            var filter = new double[3, 3] {
                {
                    oneNinth, oneNinth, oneNinth
                },
                {
                    oneNinth, oneNinth, oneNinth
                },
                {
                    oneNinth, oneNinth, oneNinth
                }
            };

            var smoother = new TreeDataSmoother <float>(tools, ConvolutionMaskSize.Mask3X3, accum,
                                                        (accum, size) => new FilterConvolver <float>(accum, filter, NullInfillMode.NoInfill));

            var result = smoother.Smooth(source);

            var resultSubGrid = result.LocateSubGridContaining(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.SubGridTreeLevels) as GenericLeafSubGrid <float>;

            resultSubGrid.Should().NotBeNull();
            resultSubGrid.Items.Should().BeEquivalentTo(sourceSubGrid.Items);
        }
示例#2
0
        public void Creation()
        {
            var tools  = new ConvolutionTools <float>();
            var accum  = new ConvolutionAccumulator_Float(CellPassConsts.NullHeight, ConvolutionMaskSize.Mask3X3);
            var filter = new double[3, 3];

            var smoother = new TreeDataSmoother <float>(tools, ConvolutionMaskSize.Mask3X3, accum,
                                                        (acc, size) => new FilterConvolver <float>(accum, filter, NullInfillMode.NoInfill));

            smoother.Should().NotBeNull();
            smoother.AdditionalBorderSize.Should().Be(3 / 2);
        }