Example #1
0
        public void UpdateDisplayInfo(int VisibleCH, int ShortInfraredCH, int FarInfraredCH)
        {
            if (_argumentProvider.DataProvider == null)
            {
                _snwFeatureCollection = null;
            }
            Dictionary <int, SnwFeature> features = new Dictionary <int, SnwFeature>();
            SnwFeature tempSnw = null;
            RasterPixelsVisitor <UInt16> rpVisitor = new RasterPixelsVisitor <UInt16>(_argumentProvider);

            Rectangle rect = new Rectangle(0, 0, _argumentProvider.DataProvider.Width, _argumentProvider.DataProvider.Height);

            int[] aoi = null;//积雪信息提示要求不使用AOI。
            rpVisitor.VisitPixel(rect, aoi,
                                 new int[] { VisibleCH, ShortInfraredCH, FarInfraredCH },
                                 (index, values) =>
            {
                tempSnw               = new SnwFeature();
                tempSnw.Ndsi          = (Int16)((values[0] - values[1]) * 1000f / (values[0] + values[1]));
                tempSnw.Visible       = values[0];
                tempSnw.ShortInfrared = values[1];
                tempSnw.FarInfrared   = values[2];
                features.Add(index, tempSnw);
            }
                                 );
            _snwFeatureCollection = new SnwFeatureCollection("积雪辅助信息", features);;
        }
Example #2
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null || _argumentProvider.DataProvider == null)
            {
                return(null);
            }
            string algname = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (string.IsNullOrEmpty(algname))
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            if (algname == "SNWExtract")
            {
                IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
                int             visiBandNo     = TryGetBandNo(bandNameRaster, "Visible");
                int             sIBandNo       = TryGetBandNo(bandNameRaster, "ShortInfrared");
                int             fIBandNo       = TryGetBandNo(bandNameRaster, "FarInfrared");
                double          visiBandZoom   = (double)_argumentProvider.GetArg("Visible_Zoom");
                double          siBandZoom     = (double)_argumentProvider.GetArg("ShortInfrared_Zoom");
                double          fiBandZoom     = (double)_argumentProvider.GetArg("FarInfrared_Zoom");
                if (visiBandNo <= 0 || sIBandNo <= 0 || fIBandNo <= 0 || visiBandZoom <= 0 || siBandZoom <= 0 || fiBandZoom <= 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                string express = string.Format(@"(band{1}/{4}f > var_ShortInfraredMin) && (band{1}/{4}f< var_ShortInfraredMax) && 
                                (band{2}/{5}f< var_FarInfraredMax) && (band{2}/{5}f > var_FarInfraredMin) && (band{0}/{3}f> var_VisibleMin) && 
                                ((float)(band{0}/{3}f-band{1}/{4}f)/(band{0}/{3}f+band{1}/{4}f)> var_NDSIMin) && 
                                ((float)(band{0}/{3}f-band{1}/{4}f)/(band{0}/{3}f+band{1}/{4}f)< var_NDSIMax)&&
                                (band{0}/{3}f< var_VisibleMax)", visiBandNo, sIBandNo, fIBandNo, visiBandZoom, siBandZoom, fiBandZoom);
                int[]  bandNos = new int[] { visiBandNo, sIBandNo, fIBandNo };
                IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();
                extracter.Reset(_argumentProvider, bandNos, express);
                int width  = _argumentProvider.DataProvider.Width;
                int height = _argumentProvider.DataProvider.Height;
                IPixelIndexMapper result = PixelIndexMapperFactory.CreatePixelIndexMapper("SNW", width, height, _argumentProvider.DataProvider.CoordEnvelope, _argumentProvider.DataProvider.SpatialRef);
                try
                {
                    SnwFeatureCollection featureInfo = SnwDisplayInfo.GetDisplayInfo(_argumentProvider, visiBandNo, sIBandNo, fIBandNo);
                    result.Tag = featureInfo;
                }
                catch
                {
                    result.Tag = new SnwFeatureCollection("积雪辅助信息计算失败", null);
                }
                extracter.Extract(result);
                return(result);
            }
            else
            {
                PrintInfo("指定的算法\"" + algname + "\"没有实现。");
                return(null);
            }
        }