Esempio n. 1
0
        public object[] GetStretcher(IRasterDataProvider dataProvider, int[] bandNos, float percent)
        {
            int[] bNos = bandNos.Distinct().ToArray();
            Dictionary <int, RasterQuickStatResult> results;
            IProgressMonitor progress = _smartSession.ProgressMonitorManager.DefaultProgressMonitor;

            try
            {
                progress.Reset("正在执行直方图统计...", 100);
                progress.Start(false);
                IRasterQuickStatTool stat = new RasterQuickStatTool();
                results = stat.Compute(dataProvider, null, bNos,
                                       (idx, tip) =>
                {
                    progress.Boost(idx, "正在执行直方图统计...");
                });
            }
            finally
            {
                progress.Finish();
            }
            RasterQuickStatResult[] rts = new RasterQuickStatResult[bandNos.Length];
            for (int i = 0; i < bandNos.Length; i++)
            {
                rts[i] = results[bandNos[i]];
            }
            //
            object[] stretchers = GetStretcher(dataProvider.DataType, rts, percent);
            return(stretchers);
        }
Esempio n. 2
0
        public object PercentXStretcher(int bandNo, float percent)
        {
            Dictionary <int, RasterQuickStatResult> results;
            IRasterQuickStatTool stat = new RasterQuickStatTool();

            results = stat.Compute(this, null, new int[] { bandNo }, null);
            RasterQuickStatResult rst = results[bandNo];

            //
            object[] stretchers = GetStretcher(this.DataType, new RasterQuickStatResult[] { rst }, percent);
            return(stretchers[0]);
        }
Esempio n. 3
0
        private void DisplayStatResult(string fileName, Dictionary <int, RasterQuickStatResult> results)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(fileName);
            foreach (int bandNo in results.Keys)
            {
                RasterQuickStatResult result = results[bandNo];
                sb.AppendLine("    BandNo " + bandNo.ToString());
                sb.AppendLine("    MinValue:".PadRight(20) + result.MinValue.ToString("0.####"));
                sb.AppendLine("    MaxValue:".PadRight(20) + result.MaxValue.ToString("0.####"));
                sb.AppendLine("    MeanValue:".PadRight(20) + result.MeanValue.ToString("0.####"));
                sb.AppendLine("    Histogram,Bin=".PadRight(20) + result.HistogramResult.Bin.ToString());
                HistogramResult histResult = result.HistogramResult;
                int             buckets    = histResult.ActualBuckets;
                sb.AppendLine("DN".PadLeft(15) + "Count(Npts)".PadLeft(15) + "Total Count".PadLeft(15) + "Percent".PadLeft(15) + "Acc Percent".PadLeft(15));
                double minValue   = result.MinValue;
                double bin        = histResult.Bin;
                long   accCount   = 0;
                double percent    = 0;
                double accPercent = 0;
                for (int i = 0; i < buckets; i++)
                {
                    accCount   += histResult.Items[i];
                    percent     = 100 * histResult.Items[i] / (float)histResult.PixelCount;
                    accPercent += percent;
                    string sLine = (minValue + i * bin).ToString().PadLeft(15) +
                                   histResult.Items[i].ToString().PadLeft(15) +
                                   accCount.ToString().PadLeft(15) +
                                   percent.ToString("0.####").PadLeft(15) +
                                   accPercent.ToString("0.####").PadLeft(15);
                    sb.AppendLine(sLine);
                }
            }
            richTextBox1.Text = sb.ToString();
        }