Esempio n. 1
0
        public void Creation_Mean2()
        {
            var accumulator = new ConvolutionAccumulator_Float(CellPassConsts.NullHeight, ConvolutionMaskSize.Mask3X3);
            var filter      = new MeanFilter <float>(accumulator, ConvolutionMaskSize.Mask3X3, NullInfillMode.NoInfill);

            filter.Should().NotBeNull();
        }
Esempio n. 2
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();
            });
        }
Esempio n. 3
0
 private void meanButton_Click(object sender, EventArgs e)
 {
     if (otherFiltersInputImgBox.Image != null)
     {
         var inputBitmap          = new Bitmap(otherFiltersInputImgBox.Image);
         var meanFilterMaskClient = new MeanFilter(inputBitmap,
                                                   Settings.Default.StoreAsColorWherePossible);
         otherFiltersOutputImgBox.Image = meanFilterMaskClient.Filter();
     }
 }