Example #1
0
        public Dictionary <int, RasterQuickStatResult> Compute(IRasterDataProvider dataProvider, int[] aoi, int[] bandNos, Action <int, string> progressTracker)
        {
            if (dataProvider == null)
            {
                throw new ArgumentNullException("dataProvider");
            }
            if (bandNos == null || bandNos.Length == 0)
            {
                throw new ArgumentNullException("bandNos");
            }
            int minBandNo = bandNos.Min(), maxBandNo = bandNos.Max();

            if (minBandNo < 1 || maxBandNo > dataProvider.BandCount)
            {
                throw new IndexOutOfRangeException("bandNo");
            }
            //
            double[]             minValues  = new double[bandNos.Length];
            double[]             maxValues  = new double[bandNos.Length];
            double[]             meanValues = new double[bandNos.Length];
            IMaxMinValueComputer computer   = MaxMinValueComputerFactory.GetMaxMinValueComputer(dataProvider.DataType);

            IRasterBand[] srcRasters        = new IRasterBand[bandNos.Length];
            for (int i = 0; i < bandNos.Length; i++)
            {
                srcRasters[i] = dataProvider.GetRasterBand(bandNos[i]);
            }
            //
            computer.Compute(srcRasters, aoi, out minValues, out maxValues, out meanValues, progressTracker);
            //
            Dictionary <int, RasterQuickStatResult> results = new Dictionary <int, RasterQuickStatResult>();
            List <IRasterBand> rasterBands = new List <IRasterBand>();
            int b = 0;

            foreach (int bandNo in bandNos)
            {
                IRasterBand rstBand = dataProvider.GetRasterBand(bandNo);
                rasterBands.Add(rstBand);
                RasterQuickStatResult result = BuildStatResult(rstBand, minValues[b], maxValues[b], meanValues[b]);
                if (result != null)
                {
                    results.Add(bandNo, result);
                }
                b++;
            }
            //
            IHistogramComputer histogramComputer = HistogramComputerFactory.GetHistogramComputer(dataProvider.DataType);

            //
            if (aoi == null || aoi.Length == 0)
            {
                histogramComputer.Compute(rasterBands.ToArray(), results.Values.ToArray(), progressTracker);
            }
            else
            {
                histogramComputer.Compute(rasterBands.ToArray(), aoi, results.Values.ToArray(), progressTracker);
            }
            //
            return(results);
        }
Example #2
0
        public void Reset(IRasterDataProvider dataProvider, int xBandNo, int yBandNo, int[] aoi, XYAxisEndpointValue endpointValues, LinearFitObject fitObj, Action <int, string> progressTracker)
        {
            _fitObj       = fitObj;
            _dataProvider = dataProvider;
            _xBandNo      = xBandNo;
            _yBandNo      = yBandNo;
            _fileName     = _dataProvider.fileName;
            _xBandName    = Path.GetFileName(_fileName) + " (Band " + _xBandNo.ToString() + ")";
            _yBandName    = Path.GetFileName(_fileName) + " (Band " + _yBandNo.ToString() + ")";
            _aoi          = aoi;
            //
            IMaxMinValueComputer c = MaxMinValueComputerFactory.GetMaxMinValueComputer(dataProvider.DataType);

            double[] minValues  = new double[2];
            double[] maxValues  = new double[2];
            double[] meanValues = new double[2];
            c.Compute(new IRasterBand[] { dataProvider.GetRasterBand(xBandNo), dataProvider.GetRasterBand(yBandNo) }, aoi, out minValues, out maxValues, out meanValues, progressTracker);
            _minValueXBand = endpointValues.MinX;
            _maxValueXBand = endpointValues.MaxX;
            _minValueYBand = endpointValues.MinY;
            _maxValueYBand = endpointValues.MaxY;
            _oMinValueX    = minValues[0];
            _oMaxValueX    = maxValues[0];
            //
            _visitor = ScatterPixelVisitorFactory.GetVisitor(_dataProvider.DataType);
            _visitor.Init(_dataProvider.GetRasterBand(xBandNo), _dataProvider.GetRasterBand(yBandNo));
        }
Example #3
0
        public void Reset(IRasterDataProvider dataProvider, int xBandNo, int yBandNo, double[] xBandInvalidValue, double[] yBandInvalidValue, int[] aoi, LinearFitObject fitObj, Action <int, string> progressTracker)
        {
            _fitObj       = fitObj;
            _dataProvider = dataProvider;
            _xBandNo      = xBandNo;
            _yBandNo      = yBandNo;
            _fileName     = _dataProvider.fileName;
            string[] filenames = _fileName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (filenames.Length == 2)
            {
                _xBandName = Path.GetFileName(filenames[0]) + " (Band " + _xBandNo.ToString() + ")";
                _yBandName = Path.GetFileName(filenames[1]) + " (Band " + _yBandNo.ToString() + ")";
                _fileName  = "";
            }
            _aoi = aoi;
            //
            IMaxMinValueComputer c = MaxMinValueComputerFactory.GetMaxMinValueComputer(dataProvider.DataType);

            double[] minValues  = new double[2];
            double[] maxValues  = new double[2];
            double[] meanValues = new double[2];
            c.Compute(new IRasterBand[] { dataProvider.GetRasterBand(xBandNo), dataProvider.GetRasterBand(yBandNo) }, aoi, new double[][] { xBandInvalidValue, yBandInvalidValue }, out minValues, out maxValues, out meanValues, progressTracker);
            _minValueXBand = minValues[0];
            _maxValueXBand = maxValues[0];
            _minValueYBand = minValues[1];
            _maxValueYBand = maxValues[1];
            _oMinValueX    = _minValueXBand;
            _oMaxValueX    = _maxValueXBand;
            //
            _visitor = ScatterPixelVisitorFactory.GetVisitor(_dataProvider.DataType);
            _visitor.Init(_dataProvider.GetRasterBand(xBandNo), _dataProvider.GetRasterBand(yBandNo));
        }
Example #4
0
        public void Reset(enumDataType datatype, Object xData, Object yData, XYAxisEndpointValue endpointValues, string title, string xaxisname, string yaxisname, LinearFitObject fitObj, Action <int, string> progressTracker)
        {
            _fitObj         = fitObj;
            _graphTitleName = title;
            _xAxisName      = xaxisname;
            _yAxisName      = yaxisname;

            IMaxMinValueComputer c = MaxMinValueComputerFactory.GetMaxMinValueComputer(enumDataType.Double);

            double[] minValues  = new double[2];
            double[] maxValues  = new double[2];
            double[] meanValues = new double[2];
            c.DirectCompute(2, new double[][] { xData as double[], yData as double[] }, minValues, maxValues, meanValues);
            _minValueXBand = endpointValues.MinX;
            _maxValueXBand = endpointValues.MaxX;
            _minValueYBand = endpointValues.MinY;
            _maxValueYBand = endpointValues.MaxY;
            _oMinValueX    = minValues[0];
            _oMaxValueX    = maxValues[0];
            //
            _visitor = ScatterPixelVisitorFactory.GetVisitor(datatype);
            _visitor.InitObj(xData, yData);
        }