Ejemplo n.º 1
0
        private IExtractResult FIRGAlgorithm()
        {
            IRasterDataProvider prd            = _argumentProvider.DataProvider;
            IBandNameRaster     bandNameRaster = prd as IBandNameRaster;
            int    VisibleCH        = TryGetBandNo(bandNameRaster, "Visible");
            int    NearInfraredCH   = TryGetBandNo(bandNameRaster, "NearInfrared");
            int    FarInfraredCH    = TryGetBandNo(bandNameRaster, "FarInfrared");
            double VisibleZoom      = (double)_argumentProvider.GetArg("Visible_Zoom");
            double NearInfraredZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
            double FarInfraredZoom  = (double)_argumentProvider.GetArg("FarInfrared_Zoom");

            if (VisibleCH == -1 || FarInfraredCH == -1 || NearInfraredCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            string express = string.Format(@"NDVI(band{1},band{0})  <= var_NDVIMax &&
                                             band{0}/" + VisibleZoom + @"f <= var_VisibleMax &&
                                             band{1}/" + NearInfraredZoom + @"f <= var_NearInfraredMax &&
                                             band{2}/" + FarInfraredZoom + @"f >= var_FarInfraredMin",
                                           VisibleCH, NearInfraredCH, FarInfraredCH);

            int[] bandNos = new int[] { VisibleCH, NearInfraredCH, FarInfraredCH };
            IThresholdExtracter <Int16> extracter = new SimpleThresholdExtracter <Int16>();

            extracter.Reset(_argumentProvider, bandNos, express);

            IPixelIndexMapper result = PixelIndexMapperFactory.CreatePixelIndexMapper("FIRE", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);

            extracter.Extract(result);
            result.Tag = new FirGFeatureCollection("火区辅助信息", GetDisplayInfo(VisibleCH, NearInfraredCH, FarInfraredCH));
            return(result);
        }
Ejemplo n.º 2
0
        private IExtractResult ThresholdExtractMersi()
        {
            IBandNameRaster bandNameRaster    = _argumentProvider.DataProvider as IBandNameRaster;
            int             ShortInfraredCH   = TryGetBandNo(bandNameRaster, "ShortInfrared");
            int             FarInfrared11CH   = TryGetBandNo(bandNameRaster, "FarInfrared11");
            int             VisibleCH         = TryGetBandNo(bandNameRaster, "Visible");
            double          VisibleZoom       = (double)_argumentProvider.GetArg("Visible_Zoom");
            double          FarInfrared11Zoom = (double)_argumentProvider.GetArg("FarInfrared11_Zoom");
            double          ShortInfraredZoom = (double)_argumentProvider.GetArg("ShortInfrared_Zoom");

            if (FarInfrared11CH == -1 || VisibleCH == -1 || ShortInfraredCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            string express = string.Format(@" band{0}/" + VisibleZoom + @"f  > var_VisibleMin && band{0}/" + VisibleZoom + @"f  < var_VisibleMax &&
                                              band{1}/" + FarInfrared11Zoom + @"f  > var_FarInfrared11Min && band{1}/" + FarInfrared11Zoom + @"f  < var_FarInfrared11Max && 
                                              band{2}/" + ShortInfraredZoom + @"f  > var_NearInfraredMin && band{2}/" + ShortInfraredZoom + @"f  < var_NearInfraredMax && 
                                              NDVI(band{0},band{2}) > var_NDSIMin && NDVI(band{0},band{2}) < var_NDSIMax",
                                           VisibleCH, FarInfrared11CH, ShortInfraredCH);

            int[] bandNos = new int[] { VisibleCH, FarInfrared11CH, ShortInfraredCH };
            IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();

            extracter.Reset(_argumentProvider, bandNos, express);
            IRasterDataProvider prd    = _argumentProvider.DataProvider;
            IPixelIndexMapper   result = PixelIndexMapperFactory.CreatePixelIndexMapper("FOG", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);

            extracter.Extract(result);
            return(result);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        private IExtractResult ThresholdExtractRGB()
        {
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             RedCH          = TryGetBandNo(bandNameRaster, "Red");
            double          RedZoom        = (double)_argumentProvider.GetArg("Red_Zoom");

            if (RedCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            int    GreenCH   = TryGetBandNo(bandNameRaster, "Green");
            double GreenZoom = (double)_argumentProvider.GetArg("Green_Zoom");

            if (GreenCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            int    BlueCH   = TryGetBandNo(bandNameRaster, "Blue");
            double BlueZoom = (double)_argumentProvider.GetArg("Blue_Zoom");

            if (BlueCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            string express = string.Format(@"(band{0}/" + RedZoom + @"f  > var_RedMin && band{0}/" + RedZoom + @"f  < var_RedMax)&&
                                            (band{1}/" + GreenZoom + @"f  > var_GreenMin && band{1}/" + GreenZoom + @"f  < var_GreenMax)&&
                                            (band{2}/" + BlueZoom + @"f  > var_BlueMin && band{2}/" + BlueZoom + @"f  < var_BlueMax)", RedCH, GreenCH, BlueCH);

            try
            {
                int[] bandNos = new int[] { RedCH, GreenCH, BlueCH };
                if (_argumentProvider.DataProvider.DataType == enumDataType.Byte)
                {
                    IThresholdExtracter <byte> extracter = new SimpleThresholdExtracter <byte>();//这里如果用uint16时候,系统会出现崩溃
                    extracter.Reset(_argumentProvider, bandNos, express);
                    IRasterDataProvider prd    = _argumentProvider.DataProvider;
                    IPixelIndexMapper   result = PixelIndexMapperFactory.CreatePixelIndexMapper("FOG", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);
                    extracter.Extract(result);
                    return(result);
                }
                else
                {
                    PrintInfo("非真彩色数据,数据类型不是byte的。");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                PrintInfo(ex.Message);
                return(null);
            }
        }
Ejemplo n.º 5
0
        private void button13_Click(object sender, EventArgs e)
        {
            //构造参数提供者
            string fname = @"f:\\FY3A_Mersi_2010_06_24_10_00_1000M_L1B_PRJ_Whole.LDF";

            fname = @"F:\MERSI\评审火情用\EI2040714.ldf";
            Dictionary <string, object> args = new Dictionary <string, object>();

            args.Add("a", 315);
            IRasterDataProvider prd    = GeoDataDriver.Open(fname) as IRasterDataProvider;
            ArgumentProvider    argprd = new ArgumentProvider(prd, args);
            //构造判识表达式
            string express = "(band3 / 10f > var_a)";

            int[] bandNos = new int[] { 3 };
            //构造基于阈值的判识器
            IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();

            extracter.Reset(argprd, bandNos, express);
            //判识
            //result = PixelIndexMapperFactory.CreatePixelIndexMapper("Fire",prd.Width,prd.Height);
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            //extracter.Extract(result);
            //idxs = result.Indexes.ToArray();
            //sw.Stop();
            //Text = sw.ElapsedMilliseconds.ToString();
            //判识结果生成二值位图
            IBinaryBitmapBuilder builder = new BinaryBitmapBuilder();
            Size   bmSize = new Size(prd.Width, prd.Height);
            Bitmap bitmap = builder.CreateBinaryBitmap(bmSize, Color.Red, Color.Transparent);

            builder.Fill(idxs, new Size(prd.Width, prd.Height), ref bitmap);
            bitmap.Save("f:\\1.png", ImageFormat.Png);
            //判识结果永久保存
            RasterIdentify id = new RasterIdentify();

            id.ThemeIdentify      = "CMA";
            id.ProductIdentify    = "FIR";
            id.SubProductIdentify = "2VAL";
            id.Satellite          = "FY3A";
            id.Sensor             = "MERSI";
            id.Resolution         = "250M";
            id.OrbitDateTime      = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
            id.GenerateDateTime   = DateTime.Now;
            IInterestedRaster <UInt16> iir = new InterestedRaster <UInt16>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone());

            iir.Put(idxs, 1);
            iir.Dispose();
            //sw.Stop();
            //Text = sw.ElapsedMilliseconds.ToString();
        }
Ejemplo n.º 6
0
        private void SandExtructTest(string fname, Dictionary <string, object> args, string express, int[] bandNos, string saveName)
        {
            //构造参数提供者
            IRasterDataProvider prd    = GeoDataDriver.Open(fname) as IRasterDataProvider;
            ArgumentProvider    argprd = new ArgumentProvider(prd, args);
            //构造判识表达式
            //构造基于阈值的判识器
            IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();

            extracter.Reset(argprd, bandNos, express);
            //判识
            result = PixelIndexMapperFactory.CreatePixelIndexMapper("DST", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);
            Stopwatch sw = new Stopwatch();

            sw.Start();
            extracter.Extract(result);
            idxs = result.Indexes.ToArray();
            sw.Stop();
            Text = sw.ElapsedMilliseconds.ToString();
            //判识结果生成二值位图
            IBinaryBitmapBuilder builder = new BinaryBitmapBuilder();
            Size   bmSize = new Size(prd.Width / 2, prd.Height / 2);
            Bitmap bitmap = builder.CreateBinaryBitmap(bmSize, Color.Red, Color.White);

            builder.Fill(idxs, new Size(prd.Width, prd.Height), ref bitmap);
            bitmap.Save(saveName, ImageFormat.Png);
            //判识结果永久保存
            RasterIdentify id = new RasterIdentify();

            id.ThemeIdentify      = "CMA";
            id.ProductIdentify    = "SANDDUST";
            id.SubProductIdentify = "2VAL";
            id.Satellite          = "FY3A";
            id.Sensor             = "MERSI";
            id.Resolution         = "1000M";
            id.OrbitDateTime      = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
            id.GenerateDateTime   = DateTime.Now;
            IInterestedRaster <UInt16> iir = new InterestedRaster <UInt16>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone());

            iir.Put(idxs, 1);
            iir.Dispose();
        }
Ejemplo n.º 7
0
        public override IExtractResult Make(Action <int, string> progressTracker)
        {
            if (_argumentProvider == null || _argumentProvider.DataProvider == null)
            {
                return(null);
            }
            string algname = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (string.IsNullOrEmpty(algname))
            {
                return(null);
            }
            if (algname == "AquaticExtract")
            {
                int    visiBandNo   = (int)_argumentProvider.GetArg("Visible");
                int    sIBandNo     = (int)_argumentProvider.GetArg("ShortInfrared");
                int    fIBandNo     = (int)_argumentProvider.GetArg("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)
                {
                    return(null);
                }
                string express = string.Format(@"((band{2}/{5}f-band{0}/{3}f)==0 || {3}==0||{4}==0||{5}==0)? 
                                 false :((float)(band{1}/{4}f-band{0}/{3}f)/(band{2}/{5}f-band{0}/{3}f)< var_AquaExtractMax 
                                 && (float)(band{1}/{4}f-band{0}/{3}f)/(band{2}/{5}f-band{0}/{3}f)>var_AquaExtractMin)",
                                               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 memResult = PixelIndexMapperFactory.CreatePixelIndexMapper("BAG", width, height, _argumentProvider.DataProvider.CoordEnvelope, _argumentProvider.DataProvider.SpatialRef);
                extracter.Extract(memResult);
                return(memResult);
            }
            return(null);
        }
Ejemplo n.º 8
0
        public override IExtractResult Make(Action <int, string> progressTracker)
        {
            if (_argumentProvider == null || _argumentProvider.DataProvider == null)
            {
                return(null);
            }
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;

            if (_argumentProvider.GetArg("AlgorithmName").ToString() == "Cloud")
            {
                string express = "";
                int[]  bandNos = null;
                bandNos    = new int[3];
                bandNos[0] = TryGetBandNo(bandNameRaster, "Visible");
                bandNos[1] = TryGetBandNo(bandNameRaster, "NearInfrared");
                bandNos[2] = TryGetBandNo(bandNameRaster, "FarInfrared");
                double visibleZoom            = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
                double nearZoom               = (double)_argumentProvider.GetArg("Visible_Zoom");
                double farZoom                = (double)_argumentProvider.GetArg("FarInfrared_Zoom");
                string nearInfraredMin        = _argumentProvider.GetArg("NearInfraredMin").ToString();
                string nearInfraredMax        = _argumentProvider.GetArg("NearInfraredMax").ToString();
                string nearInfraredVisibleMin = _argumentProvider.GetArg("NearInfraredVisibleMin").ToString();
                string nearInfraredVisibleMax = _argumentProvider.GetArg("NearInfraredVisibleMax").ToString();
                string farInfraredMin         = _argumentProvider.GetArg("FarInfraredMin").ToString();
                string farInfraredMax         = _argumentProvider.GetArg("FarInfraredMax").ToString();
                express = string.Format(@"(band{0}/{3}>{6}*10)&&(band{0}/{3}<{7}*10)&&(((float)band{1}/{4})/(band{0}/{3})>{8})&&(((float)band{1}/{4})/(band{0}/{3})<{9})&&(band{2}/{5}>{10}*10)&&(band{2}/{5}<{11}*10)", bandNos[0], bandNos[1], bandNos[2], visibleZoom, nearZoom, farZoom, nearInfraredMin, nearInfraredMax, nearInfraredVisibleMin, nearInfraredVisibleMax, farInfraredMin, farInfraredMax);
                IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();
                extracter.Reset(_argumentProvider, bandNos, express);
                IRasterDataProvider prd       = _argumentProvider.DataProvider;
                IPixelIndexMapper   resultFLD = PixelIndexMapperFactory.CreatePixelIndexMapper("FLD", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);
                extracter.Extract(resultFLD);
                return(resultFLD);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 9
0
        private IExtractResult ThresholdAlgorithm_FY2()
        {
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int             VisibleCH      = TryGetBandNo(bandNameRaster, "Visible");
            double          VisibleZoom    = (double)_argumentProvider.GetArg("Visible_Zoom");

            if (VisibleCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }

            string express = string.Format(@"band{0}/" + VisibleZoom + @"f  > var_VisibleMin && band{0}/" + VisibleZoom + @"f  < var_VisibleMax", VisibleCH);

            try
            {
                int[] bandNos = new int[] { VisibleCH };
                if (_argumentProvider.DataProvider.DataType == enumDataType.Byte)
                {
                    IThresholdExtracter <byte> extracter = new SimpleThresholdExtracter <byte>();//这里如果用uint16时候,系统会出现崩溃
                    extracter.Reset(_argumentProvider, bandNos, express);
                    IRasterDataProvider prd    = _argumentProvider.DataProvider;
                    IPixelIndexMapper   result = PixelIndexMapperFactory.CreatePixelIndexMapper("FOG", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);
                    extracter.Extract(result);
                    return(result);
                }
                else
                {
                    PrintInfo("非静止星数据,数据类型不是byte的。");
                    return(null);
                }
            }
            catch (Exception ex)
            {
                PrintInfo(ex.Message);
                return(null);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 蓝藻云判识实现
        ///
        /// </summary>
        /// <returns></returns>
        private IExtractResult BAGAlgorithm()
        {
            Dictionary <string, string> dic = Obj2Dic(_curArguments.GetArg("ArgumentSetting"));
            //可见光波段
            int VisibleCH = Obj2int(_curArguments.GetArg("Visible"));
            //近红外波段
            int NearInfraredCH = Obj2int(_curArguments.GetArg("NearInfrared"));
            //短波红外波段
            int ShortInfraredCH = Obj2int(_curArguments.GetArg("ShortInfrared"));

            bool IsPrintFeature = bool.Parse(dic["PrintFeature"]);

            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;

            //尝试根据当前卫星载荷数据自动匹配波段信息
            if (bandNameRaster != null)
            {
                int newbandNo = -1;
                if (bandNameRaster.TryGetBandNoFromBandName(VisibleCH, out newbandNo))
                {
                    VisibleCH = newbandNo;
                }
                if (bandNameRaster.TryGetBandNoFromBandName(NearInfraredCH, out newbandNo))
                {
                    NearInfraredCH = newbandNo;
                }
                if (bandNameRaster.TryGetBandNoFromBandName(ShortInfraredCH, out newbandNo))
                {
                    ShortInfraredCH = newbandNo;
                }
            }
            //获取放大倍数信息
            double VisibleZoom       = Obj2Double(_curArguments.GetArg("Visible_Zoom"));
            double NearInfraredZoom  = Obj2Double(_curArguments.GetArg("NearInfrared_Zoom"));
            double ShortInfraredZoom = Obj2Double(_curArguments.GetArg("ShortInfrared_Zoom"));
            //获取界面配置值
            double minvisiable     = double.Parse(dic["MinVisiable"]);
            double minnearinfrared = double.Parse(dic["MinNearInFrared"]);
            double maxnsvi         = double.Parse(dic["MaxNSVI"]);
            double minndvi         = double.Parse(dic["MinNDVI"]);


            //云判识增加 近红外/短波红外>c 的判断
            // c=nsvi
            string nsvi = dic.ContainsKey("NSVI") ? dic["NSVI"] : string.Empty;

            if (VisibleCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            int bandCount = _curArguments.DataProvider == null ? -1 : _curArguments.DataProvider.BandCount;


            List <int>    bandNos = new List <int>();
            StringBuilder express = new StringBuilder();

            //波段信息
            bandNos.Add(VisibleCH);
            bandNos.Add(NearInfraredCH);
            bandNos.Add(ShortInfraredCH);
            express.Append(string.Format("(band{0}/{1}f" + " >= " + minvisiable + ")||", VisibleCH, VisibleZoom));
            express.Append(string.Format("((band{0}/{1}f)/(band{2}/{3}f)" + "  <= " + maxnsvi + " && ", NearInfraredCH, NearInfraredZoom, ShortInfraredCH, ShortInfraredZoom));
            express.Append(string.Format("band{0}/{1}f" + " >= " + minnearinfrared + " && ", NearInfraredCH, NearInfraredZoom));
            express.Append(string.Format("(float)((band{2}/{1}f - band{0}/{3}f) / (band{2}/{1}f+band{0}/{3}f)) >= " + minndvi + ")", VisibleCH, VisibleZoom, NearInfraredCH, NearInfraredZoom));
            IThresholdExtracter <Int16> extracter = new SimpleThresholdExtracter <Int16>();

            extracter.Reset(_curArguments, bandNos.ToArray(), express.ToString());
            IRasterDataProvider prd    = _curArguments.DataProvider;
            IPixelIndexMapper   result = PixelIndexMapperFactory.CreatePixelIndexMapper("0CLM", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);

            if (IsPrintFeature)
            {
                result.Tag = new CLMFeatureCollection("云辅助信息", GetBagDisplayInfo(VisibleCH, ShortInfraredCH, NearInfraredCH, prd));
            }
            extracter.Extract(result);
            return(result);
        }
Ejemplo n.º 11
0
        private IExtractResult CLMAlgorithm()
        {
            Dictionary <string, string> dic = Obj2Dic(_curArguments.GetArg("ArgumentSetting"));
            //可见光波段
            int VisibleCH = Obj2int(_curArguments.GetArg("Visible"));
            //远红外波段
            int FarInfraredCH = Obj2int(_curArguments.GetArg("FarInfrared"));
            //近红外波段
            int NearInfrared  = Obj2int(_curArguments.GetArg("NearInfrared"));
            int NDSIVisibleCH = Obj2int(_curArguments.GetArg("NDSIVisible"));
            //短波红外波段
            int             NDSIShortInfraredCH = Obj2int(_curArguments.GetArg("NDSIShortInfrared"));
            IBandNameRaster bandNameRaster      = _argumentProvider.DataProvider as IBandNameRaster;

            if (bandNameRaster != null)
            {
                int newbandNo = -1;
                if (bandNameRaster.TryGetBandNoFromBandName(VisibleCH, out newbandNo))
                {
                    VisibleCH = newbandNo;
                }
                if (bandNameRaster.TryGetBandNoFromBandName(FarInfraredCH, out newbandNo))
                {
                    FarInfraredCH = newbandNo;
                }
                if (bandNameRaster.TryGetBandNoFromBandName(NDSIVisibleCH, out newbandNo))
                {
                    NDSIVisibleCH = newbandNo;
                }
                if (bandNameRaster.TryGetBandNoFromBandName(NDSIShortInfraredCH, out newbandNo))
                {
                    NDSIShortInfraredCH = newbandNo;
                }
            }
            double VisibleZoom           = Obj2Double(_curArguments.GetArg("Visible_Zoom"));
            double FarInfraredZoom       = Obj2Double(_curArguments.GetArg("FarInfrared_Zoom"));
            double NDSIVisibleZoom       = Obj2Double(_curArguments.GetArg("NDSIVisible_Zoom"));
            double NDSIShortInfraredZoom = Obj2Double(_curArguments.GetArg("NDSIShortInfrared_Zoom"));
            //近红外放大倍数
            double NearInfraredZoom   = Obj2Double(_curArguments.GetArg("NearInfrared_Zoom"));
            string useNDSIStr         = dic.ContainsKey("UseNDSI") ? dic["UseNDSI"] : string.Empty;
            bool   useNDSI            = string.IsNullOrEmpty(useNDSIStr) ? false : bool.Parse(useNDSIStr);
            string PrintFeatrueStr    = dic.ContainsKey("PrintFeatrue") ? dic["PrintFeatrue"] : string.Empty;
            bool   PrintFeatrue       = string.IsNullOrEmpty(PrintFeatrueStr) ? false : bool.Parse(PrintFeatrueStr);
            string ndsiMin            = dic.ContainsKey("NDSIMin") ? dic["NDSIMin"] : string.Empty;
            string ndsiMax            = dic.ContainsKey("NDSIMax") ? dic["NDSIMax"] : string.Empty;
            string useNearVisiableStr = dic.ContainsKey("UseNearVisiable") ? dic["UseNearVisiable"] : string.Empty;
            bool   useNearVisiable    = string.IsNullOrEmpty(useNearVisiableStr) ? false : bool.Parse(useNearVisiableStr);
            string nearVisiableMin    = dic.ContainsKey("NearVisableMin") ? dic["NearVisableMin"] : string.Empty;
            string nearVisiableMax    = dic.ContainsKey("NearVisableMax") ? dic["NearVisableMax"] : string.Empty;
            string visibleMin         = dic.ContainsKey("VisibleMin") ? dic["VisibleMin"] : string.Empty;
            string useFarInfraredStr  = dic.ContainsKey("UseFarInfrared") ? dic["UseFarInfrared"] : string.Empty;
            bool   useFarInfrared     = string.IsNullOrEmpty(useFarInfraredStr) ? false : bool.Parse(useFarInfraredStr);
            string farInfraredMax     = dic.ContainsKey("FarInfraredMax") ? dic["FarInfraredMax"] : string.Empty;
            //云判识增加 近红外/短波红外>c 的判断
            // c=nsvi
            string nsvi = dic.ContainsKey("NSVI") ? dic["NSVI"] : string.Empty;

            if (VisibleCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            int bandCount = _curArguments.DataProvider == null ? -1 : _curArguments.DataProvider.BandCount;

            if (useFarInfrared)
            {
                if (FarInfraredCH == -1 || (bandCount != -1 && FarInfraredCH > bandCount))
                {
                    PrintInfo("获取波段序号失败,预选的波段号大于当前影像的最大波段数。");
                    return(null);
                }
            }
            if (useNDSI)
            {
                if (bandCount != -1 && (FarInfraredCH > bandCount || NDSIVisibleCH > bandCount || NDSIShortInfraredCH > bandCount))
                {
                    PrintInfo("获取波段序号失败,预选的波段号大于当前影像的最大波段数。");
                    return(null);
                }
            }
            if (useNearVisiable)
            {
                if (VisibleCH == -1 || NDSIShortInfraredCH == -1 || (bandCount != -1 && (VisibleCH > bandCount || NDSIShortInfraredCH > bandCount)))
                {
                    PrintInfo("获取波段序号失败,预选的波段号大于当前影像的最大波段数。");
                    return(null);
                }
            }
            if (bandCount != -1 && VisibleCH > bandCount)
            {
                VisibleCH = NDSIVisibleCH;
            }

            List <int>    bandNos = new List <int>();
            StringBuilder express = new StringBuilder();

            bandNos.Add(VisibleCH);
            express.Append("band" + VisibleCH + "/" + VisibleZoom + @"f  >= " + visibleMin + " && ");
            if (useNDSI)
            {
                bandNos.Add(NDSIVisibleCH);
                bandNos.Add(NDSIShortInfraredCH);
                express.Append(string.Format(@"NDVI(band{0},band{1})  >= " + ndsiMin + @" &&
                                               NDVI(band{0},band{1})  <  " + ndsiMax + " && ",
                                             NDSIVisibleCH, NDSIShortInfraredCH));
            }
            if (useFarInfrared)
            {
                bandNos.Add(FarInfraredCH);
                express.Append("band" + FarInfraredCH + "/" + FarInfraredZoom + @"f <= " + farInfraredMax + " && ");
            }
            if (useNearVisiable)
            {
                bandNos.Add(NDSIShortInfraredCH);
                bandNos.Add(VisibleCH);
                express.Append(string.Format(@"((band{0}/" + NDSIShortInfraredZoom + "f)/(band{1}/" + VisibleZoom + "f))  >= " + nearVisiableMin + @" &&
                                               ((band{0}/" + NDSIShortInfraredZoom + "f)/(band{1}/" + VisibleZoom + "f))  <  " + nearVisiableMax + @" &&",
                                             NDSIShortInfraredCH, VisibleCH));
            }
            //增加 近红外/短波红外 >c 判识条件
            if (!string.IsNullOrEmpty(nsvi))
            {
                bandNos.Add(NearInfrared);
                bandNos.Add(NDSIShortInfraredCH);
                express.Append(string.Format(@"((band{0}/" + NearInfraredZoom + "f)/(band{1}/" + NDSIShortInfraredZoom + "f))  <= " + nsvi + @" &&",
                                             NearInfrared, NDSIShortInfraredCH));
            }

            IThresholdExtracter <Int16> extracter = new SimpleThresholdExtracter <Int16>();

            extracter.Reset(_curArguments, bandNos.ToArray(), express.ToString().Substring(0, express.Length - 3));
            IRasterDataProvider prd    = _curArguments.DataProvider;
            IPixelIndexMapper   result = PixelIndexMapperFactory.CreatePixelIndexMapper("0CLM", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);

            if (PrintFeatrue)
            {
                result.Tag = new CLMFeatureCollection("云辅助信息", GetDisplayInfo(VisibleCH, NDSIShortInfraredCH, VisibleCH, FarInfraredCH,
                                                                              useNDSI, useNearVisiable, useFarInfrared, prd));
            }
            extracter.Extract(result);
            return(result);
        }
Ejemplo n.º 12
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 (algname == "BAGExtract_New")
            {
                //return GetBAG();
                return(GetCloudBAG());
            }

            if (!string.IsNullOrEmpty(algname))
            {
                double visiBandRoom = (double)_argumentProvider.GetArg("Visible_Zoom");
                double niBandRoom   = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
                if (algname == "BAGExtract")
                {
                    MinNDVI = (double)_argumentProvider.GetArg("NDVIMin");
                    MaxNDVI = (double)_argumentProvider.GetArg("NDVIMax");
                }
                else if (algname == "BAGExtract_Test")
                {
                    UCSetNDVITool uccontrl = _argumentProvider.GetArg("ucSetNDVITool") as UCSetNDVITool;
                    if (uccontrl.ckbaoi.Checked)
                    {
                        uccontrl.btnGetAOIIndex(null, null);
                    }
                    else
                    {
                        MinNDVI = uccontrl.txtndvimin.Value;
                        MaxNDVI = uccontrl.txtndvimax.Value;
                    }
                }



                IRasterDataProvider prd = _argumentProvider.DataProvider;
                if (prd == null)
                {
                    PrintInfo("未能获取当前影像数据。");
                    return(null);
                }
                IBandNameRaster bandNameRaster = prd as IBandNameRaster;
                int             visiBandNo     = TryGetBandNo(bandNameRaster, "Visible");
                int             niBandNo       = TryGetBandNo(bandNameRaster, "NearInfrared");
                if (visiBandNo == -1 || niBandNo == -1 || visiBandRoom == -1 || niBandRoom == -1)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                string express = string.Format(@"({0}==0||{1}==0 )? false :((float)(band{3}/{1}f - band{2}/{0}f) / (band{2}/{0}f+ band{3}/{1}f) < {5})
                       && ((float)(band{3} /{1}f- band{2}/{0}f) / (band{3}/{1}f + band{2}/{0}f) > {4})", visiBandRoom, niBandRoom, visiBandNo, niBandNo, MinNDVI, MaxNDVI);
                int[]  bandNos = new int[] { visiBandNo, niBandNo };
                IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();
                extracter.Reset(_argumentProvider, bandNos, express);
                int width  = prd.Width;
                int height = prd.Height;
                IPixelIndexMapper memResult = PixelIndexMapperFactory.CreatePixelIndexMapper("BAG", width, height, prd.CoordEnvelope, prd.SpatialRef);
                extracter.Extract(memResult);
                memResult.Tag = new BagFeatureCollection("蓝藻辅助信息", GetDisplayInfo(memResult, visiBandNo, niBandNo));
                //计算NDVI文件
                IPixelFeatureMapper <float> ndvi = null;
                try
                {
                    ndvi = ComputeNDVIResult(_argumentProvider.DataProvider, memResult, visiBandNo, niBandNo);
                    IExtractResultBase bPCDResult = CreatPixelCoverRate(ndvi);
                    ExtractResultArray results    = new ExtractResultArray("BAG_BINS");
                    results.Add(memResult);
                    //results.Add(ndvi);
                    results.Add(bPCDResult);
                    return(results);
                }
                finally
                {
                    if (ndvi != null)
                    {
                        ndvi.Dispose();
                    }
                }
            }
            else
            {
                PrintInfo("指定的算法\"" + algname + "\"没有实现。");
                return(null);
            }
        }
Ejemplo n.º 13
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            string     express = "";
            List <int> bandNos = new List <int>();

            if (_argumentProvider == null || _argumentProvider.DataProvider == null)
            {
                return(null);
            }
            IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            object          obj            = _argumentProvider.GetArg("AlgorithmName");
            string          argName        = obj == null ? null : obj.ToString();

            if (string.IsNullOrEmpty(argName))
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            switch (argName)
            {
            case "SunDay1":
            {
                int    bandNo           = TryGetBandNo(bandNameRaster, "NearInfrared");
                double nearInfraredZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
                //配置文件中设置为float类型,但有时为float类型,有时为double型
                //double shortInfraredMin = (double)_argumentProvider.GetArg("ShortInfraredMin");
                //double shortInfraredMax = (double)_argumentProvider.GetArg("ShortInfraredMax");
                if (bandNo <= 0 || nearInfraredZoom == 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                bandNos.Add(bandNo);
                express = "(band" + bandNo + "/" + nearInfraredZoom + ">" + _argumentProvider.GetArg("ShortInfraredMin") + ")&&(band" + bandNo + "/" + nearInfraredZoom + "<" + _argumentProvider.GetArg("ShortInfraredMax") + ")";
                break;
            }

            case "SunDay2":
            {
                int    visibleNo        = TryGetBandNo(bandNameRaster, "Visible");
                int    nearInfraredNo   = TryGetBandNo(bandNameRaster, "NearInfrared");
                double visibleZoom      = (double)_argumentProvider.GetArg("Visible_Zoom");
                double nearInfraredZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
                if (visibleNo <= 0 || nearInfraredNo <= 0 || visibleZoom == 0 || nearInfraredZoom == 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                bandNos.Add(visibleNo);
                bandNos.Add(nearInfraredNo);
                express = "((band" + nearInfraredNo + "/" + nearInfraredZoom + "-band" + visibleNo + "/" + visibleZoom + ")<" + _argumentProvider.GetArg("NearInfraredVisibleMax")
                          + " && (band" + nearInfraredNo + "/" + nearInfraredZoom + ")<" + _argumentProvider.GetArg("NearInfraredMax")
                          + " && (band" + visibleNo + "/" + visibleZoom + ")<" + _argumentProvider.GetArg("VisibleMax")
                          + ")";
                break;
            }

            case "Night":
            {
                int    nightFarInfraredNo   = TryGetBandNo(bandNameRaster, "FarInfrared");
                double nightFarInfraredZoom = (double)_argumentProvider.GetArg("FarInfrared_Zoom");
                if (nightFarInfraredNo <= 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                bandNos.Add(nightFarInfraredNo);
                express = "((band" + nightFarInfraredNo + "/" + nightFarInfraredZoom + ")>" + _argumentProvider.GetArg("FarInfraredMin") + @" &&
                                    (band" + nightFarInfraredNo + "/" + nightFarInfraredZoom + ")<" + _argumentProvider.GetArg("FarInfraredMax") + ")";
                break;
            }

            case "ThinCloud":
            {
                int    visibleNo        = TryGetBandNo(bandNameRaster, "Visible");
                int    nearInfraredNo   = TryGetBandNo(bandNameRaster, "NearInfrared");
                double visibleZoom      = (double)_argumentProvider.GetArg("Visible_Zoom");
                double nearInfraredZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
                if (visibleNo <= 0 || nearInfraredNo <= 0 || visibleZoom == 0 || nearInfraredZoom == 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                bandNos.Add(visibleNo);
                bandNos.Add(nearInfraredNo);
                express = "(band" + visibleNo + "==0)?false:((((float)band" + nearInfraredNo + "/" + nearInfraredZoom + ")/(band" + visibleNo + "/" + visibleZoom + ")>" + _argumentProvider.GetArg("NearInfraredVisibleMin") + ")&&(((float)band" + nearInfraredNo + "/" + nearInfraredZoom + ")/(band" + visibleNo + "/" + visibleZoom + ")<" + _argumentProvider.GetArg("NearInfraredVisibleMax") + "))";
                break;
            }

            case "Fog":
            {
                int    middleInfraredNo      = TryGetBandNo(bandNameRaster, "MiddleInfrared");
                int    farInfraredNo         = TryGetBandNo(bandNameRaster, "FarInfrared");
                double fogMiddleInfraredZoom = (double)_argumentProvider.GetArg("MiddleInfrared_Zoom");
                double fogFarInfraredZoom    = (double)_argumentProvider.GetArg("FarInfrared_Zoom");
                if (middleInfraredNo <= 0 || farInfraredNo <= 0 || fogFarInfraredZoom == 0 || fogMiddleInfraredZoom == 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                object midFar = _argumentProvider.GetArg("MiddleInfraredFarInfrared");
                float  value  = float.MinValue;
                if (!float.TryParse(midFar.ToString(), out value))
                {
                    PrintInfo("亮温差不在合法范围内,请重新获取。");
                    return(null);
                }
                bandNos.Add(middleInfraredNo);
                bandNos.Add(farInfraredNo);
                express = "(band" + middleInfraredNo + "/" + fogMiddleInfraredZoom + "-band" + farInfraredNo + "/" + fogFarInfraredZoom + ")>" + value;
                break;
            }

            case "NDVI":
            {
                int    visibleNo              = TryGetBandNo(bandNameRaster, "Visible");
                int    nearInfraredNo         = TryGetBandNo(bandNameRaster, "NearInfrared");
                double ndviVisibleZoom        = (double)_argumentProvider.GetArg("Visible_Zoom");
                double ndvitcNearInfraredZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
                if (visibleNo <= 0 || nearInfraredNo <= 0 || ndvitcNearInfraredZoom == 0 || ndvitcNearInfraredZoom == 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                bandNos.Add(visibleNo);
                bandNos.Add(nearInfraredNo);
                express = "(band" + nearInfraredNo + "/" + ndvitcNearInfraredZoom + "+band" + visibleNo + "/" + ndviVisibleZoom + ")==0?false:((band" + nearInfraredNo + "/" + ndvitcNearInfraredZoom + "-band" + visibleNo + "/" + ndviVisibleZoom + ")" + " /(float)(band" + nearInfraredNo + "/" + ndvitcNearInfraredZoom + "+band" + visibleNo + "/" + ndviVisibleZoom + ")>" + _argumentProvider.GetArg("VisibleNearInfraredMin") + ")&&((band" + nearInfraredNo + "/" + ndvitcNearInfraredZoom + "-band" + visibleNo + "/" + ndviVisibleZoom + ")" + "/(float)(band" + nearInfraredNo + "/" + ndvitcNearInfraredZoom + "+band" + visibleNo + "/" + ndviVisibleZoom + ")<" + _argumentProvider.GetArg("VisibleNearInfraredMax") + ")";
                break;
            }

            case "GFProcess":
            {
                int    bandNo   = TryGetBandNo(bandNameRaster, "band");
                double bandZoom = (double)_argumentProvider.GetArg("band_Zoom");
                if (bandNo <= 0 || bandZoom <= 0)
                {
                    PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                    return(null);
                }
                bandNos.Add(bandNo);
                express = "((band" + bandNo + "/" + bandZoom + ")>=" + _argumentProvider.GetArg("band1Min") + ")&&((band" + bandNo + "/" + bandZoom + ")<" + _argumentProvider.GetArg("band1Max") + ")";
                break;
            }

            default:
            {
                PrintInfo("指定的算法\"" + argName + "\"没有实现。");
                return(null);
            }
            }
            IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();

            extracter.Reset(_argumentProvider, bandNos.ToArray(), express);
            IRasterDataProvider prd       = _argumentProvider.DataProvider;
            IPixelIndexMapper   resultFLD = PixelIndexMapperFactory.CreatePixelIndexMapper("FLD", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);

            extracter.Extract(resultFLD);

            CreateStageAreaInfo();
            return(resultFLD);
        }
Ejemplo n.º 14
0
        private void 沙尘能见度AOI_Click(object sender, EventArgs e)
        {
            //首先进行沙尘判识,得出判识出的沙尘区域
            string fname = @"H:\产品使用数据\01_沙尘\2011年04月30日\FY3A_VIRRX_GBAL_L1_20110430_0305_1000M_MS_PRJ_DXX.LDF";
            Dictionary <string, object> extractArgs = new Dictionary <string, object>();

            extractArgs.Add("a", 28);
            extractArgs.Add("b", 78);
            extractArgs.Add("c", 245);
            extractArgs.Add("d", 293);
            extractArgs.Add("f", 0);
            extractArgs.Add("g", 20);
            extractArgs.Add("h", 15);
            extractArgs.Add("i", 250);
            IRasterDataProvider prd    = GeoDataDriver.Open(fname) as IRasterDataProvider;
            ArgumentProvider    argprd = new ArgumentProvider(prd, extractArgs);
            string extractExpress      = "((band2*) > var_a) && (band2/10f < var_b) && (band5/10f > var_c) && (band5/10f < var_d) && "
                                         + "(band6/10f > var_a) && ((band6 - band2)>var_f)  && ((band6/10f - band5/10f + var_i)>var_h)";

            //band2:可见光,0.525~0.575(波长范围)
            //band5:远红外,10.3~11.55
            //band6:短波红外,1.60~1.69
            int[] exBandNos = new int[] { 2, 5, 6 };
            IThresholdExtracter <UInt16> thrExtracter = new SimpleThresholdExtracter <UInt16>();

            thrExtracter.Reset(argprd, exBandNos, extractExpress);
            Stopwatch sw = new Stopwatch();

            sw.Start();
            //extractResult = new MemPixelIndexMapper("SAND", 1000);
            thrExtracter.Extract(extractResult);
            idxs = extractResult.Indexes.ToArray(); //获取到判识结果

            //将判识结果作为AOI传入进行能见度计算
            string express = "(UInt16)Math.Round(1000 * Math.Pow(Math.E,(var_visibleA + var_visibleB * band1/10f + var_visibleC * band2/10f + var_visibleD * band6/10f + var_visibleE * band4/10f + var_visibleF *(band6/10f - band4/10f + var_shortFar))),0)";
            Dictionary <string, object> args = new Dictionary <string, object>();

            args.Add("visibleA", 44.7603);
            args.Add("visibleB", 0.181571);
            args.Add("visibleC", -0.332972);
            args.Add("visibleD", 0.122736);
            args.Add("visibleE", -0.144287);
            args.Add("visibleF", -0.114465);
            args.Add("shortFar", 253);
            int[]            bandNos     = new int[] { 1, 2, 6, 4 };
            ArgumentProvider argProvider = new ArgumentProvider(prd, args);

            argProvider.AOI = idxs;
            IRasterExtracter <UInt16, UInt16> extracter = new SimpleRasterExtracter <UInt16, UInt16>();

            extracter.Reset(argProvider, bandNos, express);
            result = new MemPixelFeatureMapper <UInt16>("Visibility", 1000, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);

            extracter.Extract(result);
            RasterIdentify id = new RasterIdentify();

            id.ThemeIdentify      = "CMA";
            id.ProductIdentify    = "SAND";
            id.SubProductIdentify = "VISIBILITY";
            id.Satellite          = "FY3A";
            id.Sensor             = "VIRRX";
            id.Resolution         = "1000M";
            id.OrbitDateTime      = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
            id.GenerateDateTime   = DateTime.Now;
            IInterestedRaster <UInt16> iir = new InterestedRaster <UInt16>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone());

            iir.Put(result);
            iir.Dispose();
            sw.Stop();
            Text = sw.ElapsedMilliseconds.ToString();
        }
Ejemplo n.º 15
0
        private void 海陆模板_Click(object sender, EventArgs e)
        {
            using (VectorAOITemplate v = VectorAOITemplateFactory.GetAOITemplate("海陆模版")) //贝尔湖
            {
                Size size;
                IRasterDataProvider prd;
                Envelope            evp = GetEnvelope(out size, out prd);
                Stopwatch           sw  = new Stopwatch();
                sw.Start();
                landAoi = v.GetAOI(evp, size);
                //
                int[] reverseAOI = AOIHelper.Reverse(landAoi, size);
                //IBinaryBitmapBuilder b = new BinaryBitmapBuilder();
                //Bitmap bm = b.CreateBinaryBitmap(size, Color.Red, Color.Black);
                //b.Fill(reverseAOI, size, ref bm);
                //对陆地区域使用陆地判识算法
                Dictionary <string, object> args = new Dictionary <string, object>();
                //args.Add("a", 28);
                //args.Add("b", 78);
                //args.Add("c", 245);
                //args.Add("d", 293);
                //args.Add("f", 28);
                //args.Add("g", 0);
                //args.Add("h", 15);
                //args.Add("i", 250);
                //构造判识表达式
                //string express = "((band2/10f) > var_a) && (band2/10f < var_b) && (band5/10f > var_c) && (band5/10f < var_d) && "
                //               + "(band6/10f > var_f) && ((band6 - band2)>var_g)  && ((band6/10f - band5/10f + var_i)>var_h)";
                ////band2:可见光,0.525~0.575(波长范围)
                ////band5:远红外,10.3~11.55
                ////band6:短波红外,1.60~1.69
                //int[] bandNos = new int[] { 2, 5, 6 };
                ////构造栅格计算判识器
                //ArgumentsProvider argprd = new ArgumentsProvider(prd, args);
                //argprd.AOI = reverseAOI;
                //IThresholdExtracter<UInt16> extracter = new SimpleThresholdExtracter<UInt16>();
                //extracter.Reset(argprd, bandNos, express);
                ////判识
                //landResult = new MemPixelIndexMapper("SAND", 1000);
                //extracter.Extract(landResult);
                //landInd = landResult.Indexes.ToArray();

                //对海洋区域使用海洋判识算法
                args.Clear();
                args.Add("a", 8);
                args.Add("b", 26);
                args.Add("c", 265);
                args.Add("d", 283);
                args.Add("e", -10);
                args.Add("f", 0);
                string express = "(band2/10f > var_a) && (band2/10f < var_b) && (band5/10f > var_c) && (band5/10f < var_d) && "
                                 + "(band6/10f > var_a)&& ((band6/10f - band4/10f)>var_e) &&((band2/10f - band4/10f )>var_f)";
                int[]            bandNos = new int[] { 2, 5, 6, 4 };
                ArgumentProvider argprd  = new ArgumentProvider(prd, args);
                argprd.AOI = reverseAOI;
                IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();
                extracter.Reset(argprd, bandNos, express);
                //判识
                seaResult = PixelIndexMapperFactory.CreatePixelIndexMapper("DST", prd.Width, prd.Height, prd.CoordEnvelope, prd.SpatialRef);
                extracter.Extract(seaResult);
                seaIdx = seaResult.Indexes.ToArray();

                //
                IBinaryBitmapBuilder builder = new BinaryBitmapBuilder();
                Size   bmSize = new Size(prd.Width / 2, prd.Height / 2);
                Bitmap bitmap = builder.CreateBinaryBitmap(bmSize, Color.Red, Color.White);
                builder.Fill(landInd, new Size(prd.Width, prd.Height), ref bitmap);
                bitmap.Save("h:\\陆地沙尘.png", ImageFormat.Png);
                builder.Fill(seaIdx, new Size(prd.Width, prd.Height), ref bitmap);
                bitmap.Save("h:\\海洋沙尘.png", ImageFormat.Png);
                //
                RasterIdentify id = new RasterIdentify();
                id.ThemeIdentify      = "CMA";
                id.ProductIdentify    = "SAND";
                id.SubProductIdentify = "2VAL";
                id.Satellite          = "FY3A";
                id.Sensor             = "MERSI";
                id.Resolution         = "1000M";
                id.OrbitDateTime      = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
                id.GenerateDateTime   = DateTime.Now;
                IInterestedRaster <UInt16> iir = new InterestedRaster <UInt16>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone());
                iir.Put(landInd, 1);
                iir.Put(seaIdx, 1);
                sw.Stop();
                Text = sw.ElapsedMilliseconds.ToString();
                iir.Dispose();
            }


            ////取海洋矢量作为AOI,使用海洋的判识算法
            //Dictionary<string, object> seaargs = new Dictionary<string, object>();
            //seaargs.Add("sa", 8);
            //seaargs.Add("sb", 26);
            //seaargs.Add("sc", 265);
            //seaargs.Add("sd", 283);
            //seaargs.Add("se", -10);
            //seaargs.Add("sf", 0);
            //string seaExpress = "(band2/10f > var_sa) && (band2/10f < var_sb) && (band5/10f > var_sc) && (band5/10f < var_sd) && "
            //                  + "(band6/10f > var_sa)&& ((band6/10f - band4/10f)>var_se) &&((band2/10f - band4/10f )>var_sf)";
            //int[] seabandNos = new int[] { 2, 5, 6, 4 };
            //ArgumentsProvider seaargprd = new ArgumentsProvider(prd, seaargs);
            ////构造判识表达式
            ////构造基于阈值的判识器
            //IThresholdExtracter<UInt16> seaextracter = new SimpleThresholdExtracter<UInt16>();
            //seaextracter.Reset(seaargprd, seabandNos, seaExpress);
            ////判识
            //IPixelIndexMapper searesult = new MemPixelIndexMapper("SAND", 1000);
            //seaextracter.Extract(searesult);
            //int[] seaidxs = searesult.Indexes.ToArray();


            //将两者判识的idex合并
        }
Ejemplo n.º 16
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")
            {
                int    visiBandNo   = (int)_argumentProvider.GetArg("Visible");
                int    sIBandNo     = (int)_argumentProvider.GetArg("ShortInfrared");
                int    fIBandNo     = (int)_argumentProvider.GetArg("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("MWS", width, height, _argumentProvider.DataProvider.CoordEnvelope, _argumentProvider.DataProvider.SpatialRef);
                result.Tag = SnwDisplayInfo.GetDisplayInfo(_argumentProvider, visiBandNo, sIBandNo, fIBandNo);
                extracter.Extract(result);
                return(result);
            }
            else
            {
                float[] extrParas = (float[])_argumentProvider.GetArg("Arguments");
                string  filename  = _argumentProvider.DataProvider.fileName;
                //解析文件时间,确定波段顺序
                Match  m        = DataReg.Match(Path.GetFileName(filename));
                string filedate = "";
                if (m.Success)
                {
                    filedate = m.Value;
                }
                Int32 filedateDig = Convert.ToInt32(filedate);
                int   ch18vBandNo = 3; //默认为现在使用的波段顺序
                int   ch23vBandNo = 5;
                int   ch36vBandNo = 7;
                int   ch89vBandNo = 9;
                if (algname == "MSIdentify")
                {
                    if (filedateDig < 20110412)
                    {
                        ch18vBandNo = 7;
                        ch23vBandNo = 5;
                        ch36vBandNo = 3;
                        ch89vBandNo = 1;
                    }
                    if (ch18vBandNo <= 0 || ch23vBandNo <= 0 || ch36vBandNo <= 0 || ch89vBandNo <= 0)
                    {
                        PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                        return(null);
                    }
                    //string express = string.Format(@"(((((band{1}-band{3})*0.01>=var_23V89Vmin)||((band{0}-band{2})*0.01>= var_18V36Vmin))&&((band{1}*0.01+327.68)<=var_23Vmax)&&((band{0}-band{2})*0.01>=var_18Vsec36Vmin)&&((band{1}-band{3}-band{0}+band{2})*0.01>=var_si1si2thickmin))||((((band{1}-band{3})*0.01>var_23V89Vmin)||((band{0}-band{2})*0.01> var_18V36Vmin))&&((band{1}*0.01)+327.68<=var_23Vmax)&&((band{0}-band{2})*0.01<var_18Vsec36Vmin)&&((band{1}-band{3}-band{0}+band{2})*0.01>=var_si1thinsi2min)))", ch18vBandNo, ch23vBandNo, ch36vBandNo, ch89vBandNo);
                    string express = string.Format(@"(((((band{1}-band{3})*0.01>={4})||((band{0}-band{2})*0.01>= {5}))&&((band{1}*0.01+327.68)<={6})&&((band{0}-band{2})*0.01>={7})&&((band{1}-band{3}-band{0}+band{2})*0.01>={8}))||((((band{1}-band{3})*0.01>{4})||((band{0}-band{2})*0.01> {5}))&&((band{1}*0.01)+327.68<={6})&&((band{0}-band{2})*0.01<{7})&&((band{1}-band{3}-band{0}+band{2})*0.01>={9})))", ch18vBandNo, ch23vBandNo, ch36vBandNo, ch89vBandNo, extrParas[0], extrParas[1], extrParas[2], extrParas[3], extrParas[4], extrParas[5]);
                    int[]  bandNos = new int[] { ch18vBandNo, ch23vBandNo, ch36vBandNo, ch89vBandNo };
                    IThresholdExtracter <Int16> extracter = new SimpleThresholdExtracter <Int16>();
                    extracter.Reset(_argumentProvider, bandNos, express);
                    int width  = _argumentProvider.DataProvider.Width;
                    int height = _argumentProvider.DataProvider.Height;
                    IPixelIndexMapper result = PixelIndexMapperFactory.CreatePixelIndexMapper("MWS", width, height, _argumentProvider.DataProvider.CoordEnvelope, _argumentProvider.DataProvider.SpatialRef);
                    //由于当数据过大(如全球范围数据时),分块缓存不足,因此注释掉。
                    //result.Tag = SnwDisplayInfo.GetDisplayInfoMS(_argumentProvider, ch18vBandNo, ch23vBandNo, ch36vBandNo, ch89vBandNo);
                    extracter.Extract(result);
                    return(result);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 17
0
        public IExtractResult GetBAG()
        {
            double        visiBandRoom = (double)_argumentProvider.GetArg("Visible_Zoom");
            double        niBandRoom   = (double)_argumentProvider.GetArg("NearInfrared_Zoom");
            bool          needcloud    = (bool)_argumentProvider.GetArg("isAppCloud");
            UCSetNearTool uccontrl     = _argumentProvider.GetArg("UCSetNearTool") as UCSetNearTool;

            if (uccontrl.ckbone.Checked)
            {
                uccontrl.btnGetAOIIndex(null, null);
            }
            MinNear = double.Parse(uccontrl.txtnearmin.Text) * 100;//放大调节 跟界面参数设置有关
            IRasterDataProvider prd = _argumentProvider.DataProvider;

            if (prd == null)
            {
                PrintInfo("未能获取当前影像数据。");
                return(null);
            }
            IBandNameRaster bandNameRaster = prd as IBandNameRaster;
            int             visiBandNo     = TryGetBandNo(bandNameRaster, "Visible");
            int             niBandNo       = TryGetBandNo(bandNameRaster, "NearInfrared");
            int             shortBandNo    = TryGetBandNo(bandNameRaster, "ShortInfrared");

            if (visiBandNo == -1 || niBandNo == -1 || visiBandRoom == -1 || niBandRoom == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。");
                return(null);
            }
            string express      = string.Format("band{0}/{1}f" + " >= " + MinNear, niBandNo, niBandRoom);
            string cloudexpress = GetCloudExpress();

            if (needcloud)
            {
                express = string.Format("{0} && ({1})", express, cloudexpress);
            }
            int[] bandNos = new int[] { visiBandNo, niBandNo, shortBandNo };
            IThresholdExtracter <UInt16> extracter = new SimpleThresholdExtracter <UInt16>();

            extracter.Reset(_argumentProvider, bandNos, express);
            int width  = prd.Width;
            int height = prd.Height;
            IPixelIndexMapper memResult = PixelIndexMapperFactory.CreatePixelIndexMapper("BAG", width, height, prd.CoordEnvelope, prd.SpatialRef);

            extracter.Extract(memResult);

            memResult.Tag = new BagFeatureCollection("蓝藻辅助信息", GetDisplayInfo(memResult, visiBandNo, niBandNo));
            //计算NDVI文件
            IPixelFeatureMapper <float> ndvi = null;

            try
            {
                ndvi = ComputeNDVIResult(_argumentProvider.DataProvider, memResult, visiBandNo, niBandNo);
                IExtractResultBase bPCDResult = CreatPixelCoverRate(ndvi);
                ExtractResultArray results    = new ExtractResultArray("BAG_BINS");
                results.Add(memResult);
                //results.Add(ndvi);
                results.Add(bPCDResult);
                return(results);
            }
            finally
            {
                if (ndvi != null)
                {
                    ndvi.Dispose();
                }
            }
        }