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(); }); }
public void FilterConvolverAssertsDimensionsMatch() { var accumulator = new ConvolutionAccumulator_Float(CellPassConsts.NullHeight, ConvolutionMaskSize.Mask3X3); var filter = new FilterConvolver <float>(accumulator, new double[3, 3], NullInfillMode.NoInfill); var smoother = new ConvolutionTools <float>(); Action act = () => smoother.Convolve(new float[3, 3], new float[4, 4], filter); act.Should().Throw <ArgumentException>().WithMessage("Dimensions of source and destination data are not the same"); }