Example #1
0
        public StdDevStretch(int actualMin, int actualMax, QuantizedStatistics stats, float numDeviationsFromMean)
            : base(actualMin, actualMax)
        {
            if (stats == null)
                throw new ArgumentNullException("stats", "StdDevStretch requires statistics.");

            m_stats = stats;
            m_deviations = numDeviationsFromMean;

            var totalDeviationFromMean = (long)(m_deviations * m_stats.StdDev);
            m_stretchMin = (int)Math.Max(ActualMin, stats.m_mean - totalDeviationFromMean);
            m_stretchMax = (int)Math.Min(ActualMax, stats.m_mean + totalDeviationFromMean);
        }
Example #2
0
        public StdDevStretch(int actualMin, int actualMax, QuantizedStatistics stats, float numDeviationsFromMean) :
            base(actualMin, actualMax)
        {
            if (stats == null)
            {
                throw new ArgumentNullException("stats", "StdDevStretch requires statistics.");
            }

            m_stats      = stats;
            m_deviations = numDeviationsFromMean;

            var totalDeviationFromMean = (long)(m_deviations * m_stats.StdDev);

            m_stretchMin = (int)Math.Max(ActualMin, stats.m_mean - totalDeviationFromMean);
            m_stretchMax = (int)Math.Min(ActualMax, stats.m_mean + totalDeviationFromMean);
        }
Example #3
0
        public PointCloudTileSource(LASFile file, PointCloudTileSet tileSet, Statistics zStats)
            : base(file, tileSet.PointCount, tileSet.Extent, file.Header.Quantization, file.Header.OffsetToPointData, (short)file.Header.PointDataRecordLength)
        {
            m_file = file;

            m_id = IdentityManager.AcquireIdentity(GetType().Name);

            m_tileSet = tileSet;
            m_tileSet.TileSource = this;

            m_statisticsZ = zStats;
            m_statisticsQuantizedZ = zStats.ConvertToQuantized(Quantization);

            m_lowResBuffer = BufferManager.AcquireBuffer(m_id, tileSet.LowResCount * PointSizeBytes);

            m_file.UpdateEVLR(new LASRecordIdentifier("Jacere", 0), TileSet);
            m_file.UpdateEVLR(new LASRecordIdentifier("Jacere", 1), StatisticsZ);
        }
Example #4
0
        private static unsafe BitmapSource CreateBitmapSource(Grid<int> grid, SQuantizedExtent3D extent, QuantizedStatistics statistics, bool useStdDevStretch, IColorHandler colorHandler, int quality)
        {
            var ramp = colorHandler as ColorRamp;
            var map = colorHandler as ColorMapDistinct;

            var bmp = new WriteableBitmap(grid.SizeX, grid.SizeY, 96, 96, System.Windows.Media.PixelFormats.Bgra32, null);
            bmp.Lock();
            var pBackBuffer = bmp.BackBuffer;
            var p = (int*)pBackBuffer;

            if (map != null)
            {
                //CreateColorBufferMap(grid, p, map);
            }
            else
            {
                if (ramp == null)
                    ramp = ColorRamp.PredefinedColorRamps.Grayscale;

                var qualityRatio = (float)quality / 100;
                var rampSize = (int)(qualityRatio * 300);

                StretchBase stretch = null;
                if(useStdDevStretch)
                    stretch = new StdDevStretch(extent.MinZ, extent.MaxZ, statistics, 2);
                else
                    stretch = new MinMaxStretch(extent.MinZ, extent.MaxZ);

                var cachedRamp = ramp.CreateCachedRamp(stretch, rampSize);

                //var sw = Stopwatch.StartNew();
                //int count = 300;
                //for (int i = 0; i < count; i++)
                {
                    CreateColorBufferMap(grid, p, cachedRamp);
                }
                //sw.Stop();
                //Context.WriteLine("fps: {0}", (double)1000 * count / sw.ElapsedMilliseconds);
            }

            bmp.AddDirtyRect(new System.Windows.Int32Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight));
            bmp.Unlock();
            bmp.Freeze();

            return bmp;
        }