コード例 #1
0
ファイル: UCComputeMixPixel.cs プロジェクト: windygu/hispeed
 private void btnFld_Click(object sender, EventArgs e)
 {
     if (this.Tag != null)
     {
         IArgumentProvider          arg = this.Tag as IArgumentProvider;
         ICurrentRasterInteractiver crt = arg.CurrentRasterInteractiver;
         if (crt != null)
         {
             int bandNI = (int)arg.GetArg("NearInfrared");
             if (bandNI <= 0)
             {
                 return;
             }
             crt.StartAOIDrawing(() =>
             {
                 float fldAvgValue = (float)Math.Round(crt.GetAvgBandValueInAOI(bandNI), 2);
                 txtFld.Text       = fldAvgValue.ToString();
             });
             //float fldAvgValue = (float)Math.Round(crt.GetAvgBandValueInAOI(bandNI),2);
             //txtFld.Text = fldAvgValue.ToString();
         }
     }
 }
コード例 #2
0
 public void ResetArgumentProvider(string satellite, string sensor, params string[] args)
 {
     if (_argumentProvider == null)
     {
         _argumentProvider = GetDefaultArgProvider(satellite, sensor, args);
     }
     else
     {
         _argumentProvider.Reset();
         IArgumentProvider prd = GetDefaultArgProvider(satellite, sensor, args);
         if (prd != null)
         {
             string[] argNames = prd.ArgNames;
             if (argNames != null)
             {
                 foreach (string name in argNames)
                 {
                     _argumentProvider.SetArg(name, prd.GetArg(name));
                 }
             }
         }
     }
 }
コード例 #3
0
        public void ResetArgumentProvider(string algIdentify)
        {
            ExtractProductIdentify pid = new ExtractProductIdentify();

            pid.ThemeIdentify      = _subProductDef.ProductDef.Theme.Identify;
            pid.ProductIdentify    = _subProductDef.ProductDef.Identify;
            pid.SubProductIdentify = _subProductDef.Identify;
            Dictionary <string, object> algShare = ReadAlgShareArg();
            IArgumentProvider           prd      = MonitoringThemeFactory.GetArgumentProvider(pid, algIdentify);

            if (prd != null)
            {
                string[] argNames = prd.ArgNames;
                if (argNames != null)
                {
                    foreach (string name in argNames)
                    {
                        _argumentProvider.SetArg(name, prd.GetArg(name));
                    }
                }
            }
            CopyAlgShareArg(algShare);
            UpdateCurrentAlgorithmDef(algIdentify);
        }
コード例 #4
0
        public string[] GetStringArray(string arugmentName)
        {
            object obj = _argumentProvider.GetArg(arugmentName);

            if (obj == null)
            {
                return(null);
            }
            string[] resultArray = obj as string[];
            if (arugmentName == "SelectedPrimaryFiles" && resultArray != null)
            {
                return(resultArray);
            }
            //
            if (arugmentName == "mainfiles" && resultArray != null)
            {
                return(resultArray);
            }
            else if (resultArray != null && obj.ToString() == "System.String[]")
            {
                return(resultArray);
            }
            else
            {
                //如果obj为数组,则obj.tostring() = System.String[];
                string[] tempSplit = obj.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (tempSplit == null || tempSplit.Length == 0)
                {
                    return(null);
                }
                List <string> result = new List <string>();
                for (int i = 0; i < tempSplit.Length; i++)
                {
                    if (File.Exists(tempSplit[i]))
                    {
                        result.Add(tempSplit[i]);
                    }
                }
                return(result.Count == 0 ? null : result.ToArray());
            }
        }
コード例 #5
0
ファイル: UCAnlysisTool.cs プロジェクト: windygu/hispeed
        public void btnGetInfos_Click(object sender, EventArgs e)
        {
            if (_arp != null)
            {
                double visiBandRoom      = (double)_arp.GetArg("Visible_Zoom");
                double niBandRoom        = (double)_arp.GetArg("NearInfrared_Zoom");
                double shortInfraredRoom = (double)_arp.GetArg("ShortInfrared_Zoom");
                IRasterDataProvider prd  = _arp.DataProvider;
                if (prd == null)
                {
                    return;
                }
                IBandNameRaster bandNameRaster      = prd as IBandNameRaster;
                int             visiBandNo          = TryGetBandNo(bandNameRaster, "Visible");
                int             niBandNo            = TryGetBandNo(bandNameRaster, "NearInfrared");
                int             shortInfraredBandNo = TryGetBandNo(bandNameRaster, "ShortInfrared");
                if (visiBandNo == -1 || niBandNo == -1 || shortInfraredBandNo == -1 || shortInfraredRoom == -1 || visiBandRoom == -1 || niBandRoom == -1)
                {
                    return;
                }
                ArgumentProvider ap   = new ArgumentProvider(prd, null);
                Size             size = new Size(prd.Width, prd.Height);
                if (_arp.AOIs != null && _arp.AOIs.Length != 0)
                {
                    cmbType.Text = GetInfoExt(_arp.AOIs);
                }
                Rectangle rect = AOIHelper.ComputeAOIRect(_arp.AOI, size);
                Dictionary <string, Dictionary <string, float> > anlysis = new Dictionary <string, Dictionary <string, float> >();
                InitAnlysisInfo(anlysis);
                int count     = 0;
                int ndviCount = 0;
                using (RasterPixelsVisitor <UInt16> visitor = new RasterPixelsVisitor <UInt16>(ap))
                {
                    visitor.VisitPixel(rect, _arp.AOI, new int[] { visiBandNo, niBandNo, shortInfraredBandNo },
                                       (index, values) =>
                    {
                        AnlysisValues(anlysis, "可见光", values[0]);
                        AnlysisValues(anlysis, "近红外", values[1]);
                        AnlysisValues(anlysis, "短波红外", values[2]);
                        if (values[1] + values[0] != 0)
                        {
                            AnlysisValues(anlysis, "NDVI", (float)Math.Round((float)(values[1] - values[0]) / (values[1] + values[0]), 4));
                            ndviCount++;
                        }
                        count++;
                    });
                }
                anlysis["可见光"]["avg"]  = (float)Math.Round(anlysis["可见光"]["avg"] / count, 4);
                anlysis["近红外"]["avg"]  = (float)Math.Round(anlysis["近红外"]["avg"] / count, 4);
                anlysis["短波红外"]["avg"] = (float)Math.Round(anlysis["短波红外"]["avg"] / ndviCount, 4);
                anlysis["NDVI"]["avg"] = (float)Math.Round(anlysis["NDVI"]["avg"] / ndviCount, 4);
                using (RasterPixelsVisitor <UInt16> visitor = new RasterPixelsVisitor <UInt16>(ap))
                {
                    visitor.VisitPixel(rect, _arp.AOI, new int[] { visiBandNo, niBandNo, shortInfraredBandNo },
                                       (index, values) =>
                    {
                        anlysis["可见光"]["pc"]  += (float)Math.Pow(values[0] - anlysis["可见光"]["avg"], 2);
                        anlysis["近红外"]["pc"]  += (float)Math.Pow(values[1] - anlysis["近红外"]["avg"], 2);
                        anlysis["短波红外"]["pc"] += (float)Math.Pow(values[2] - anlysis["短波红外"]["avg"], 2);
                        if (values[1] + values[0] != 0)
                        {
                            anlysis["NDVI"]["pc"] += (float)Math.Pow((float)(values[1] - values[0]) / (values[1] + values[0]) - anlysis["NDVI"]["avg"], 2);
                        }
                    });
                }
                anlysis["可见光"]["pc"]  = (float)Math.Round(Math.Sqrt(anlysis["可见光"]["pc"]) / count, 4);
                anlysis["近红外"]["pc"]  = (float)Math.Round(Math.Sqrt(anlysis["近红外"]["pc"]) / count, 4);
                anlysis["短波红外"]["pc"] = (float)Math.Round(Math.Sqrt(anlysis["短波红外"]["pc"]) / count, 4);
                anlysis["NDVI"]["pc"] = (float)Math.Round(Math.Sqrt(anlysis["NDVI"]["pc"]) / ndviCount, 4);

                StringBuilder sb = new StringBuilder();
                sb.Append(string.Format("可见光:\n  最小值:{0}\n  最大值:{1}\n  平均值:{2}\n  偏差值:{3}\n", anlysis["可见光"]["min"], anlysis["可见光"]["max"], anlysis["可见光"]["avg"], anlysis["可见光"]["pc"]));
                sb.Append(string.Format("近红外:\n  最小值:{0}\n  最大值:{1}\n  平均值:{2}\n  偏差值:{3}\n", anlysis["近红外"]["min"], anlysis["近红外"]["max"], anlysis["近红外"]["avg"], anlysis["近红外"]["pc"]));
                sb.Append(string.Format("NDVI:\n  最小值:{0}\n  最大值:{1}\n  平均值:{2}\n  偏差值:{3}\n", anlysis["NDVI"]["min"], anlysis["NDVI"]["max"], anlysis["NDVI"]["avg"], anlysis["NDVI"]["pc"]));
                sb.Append(string.Format("短波红外:\n  最小值:{0}\n  最大值:{1}\n  平均值:{2}\n  偏差值:{3}\n", anlysis["短波红外"]["min"], anlysis["短波红外"]["max"], anlysis["短波红外"]["avg"], anlysis["短波红外"]["pc"]));
                txtInfos.Text = sb.ToString();

                InitWriteTxt(anlysis);
            }
        }
コード例 #6
0
ファイル: SubProductVTIDRT.cs プロジェクト: windygu/hispeed
        private IExtractResult VTIAlgorithm()
        {
            int NDVIBandCH        = (int)_curArguments.GetArg("NDVIBand");
            int NDVIBackBandMinCH = (int)_curArguments.GetArg("NDVIBackBandMin");
            int NDVIBackBandMaxCH = (int)_curArguments.GetArg("NDVIBackBandMax");

            int LSTBandCH        = (int)_curArguments.GetArg("LSTBand");
            int LSTBackBandMinCH = (int)_curArguments.GetArg("LSTBackBandMin");
            int LSTBackBandMaxCH = (int)_curArguments.GetArg("LSTBackBandMax");

            double NDVIZoom     = (float)_curArguments.GetArg("NDVIZoom");
            double NDVIBackZoom = (float)_curArguments.GetArg("NDVIBackZoom");

            double LSTZoom     = (float)_curArguments.GetArg("LSTZoom");
            double LSTBackZoom = (float)_curArguments.GetArg("LSTBackZoom");

            float ndviVaildMin = (float)_curArguments.GetArg("ndviVaildMin");
            float ndviVaildMax = (float)_curArguments.GetArg("ndviVaildMax");

            float lstVaildMin = (float)_curArguments.GetArg("lstVaildMin");
            float lstVaildMax = (float)_curArguments.GetArg("lstVaildMax");

            double VTIZoom  = (float)_curArguments.GetArg("VTIZoom");
            string errorStr = null;

            if (NDVIBandCH == -1 || NDVIBackBandMinCH == -1 || NDVIBackBandMaxCH == -1 || LSTBandCH == -1 || LSTBackBandMinCH == -1 || LSTBackBandMaxCH == -1 ||
                _curArguments.GetArg("NDVIFile") == null || _curArguments.GetArg("NDVIBackFile") == null ||
                _curArguments.GetArg("LSTFile") == null || _curArguments.GetArg("LSTBackFile") == null)
            {
                errorStr = "VTI生产所用文件或通道未设置完全,请检查!";
                return(null);
            }
            string[] ndviFileNames = GetStringArray("NDVIFile");
            string[] lstFileNames  = GetStringArray("LSTFile");


            string NDVIFile = ndviFileNames == null || ndviFileNames.Length == 1 ? _curArguments.GetArg("NDVIFile").ToString() : MAxValue(ndviFileNames, NDVIBandCH, (float)NDVIZoom);

            if (ndviFileNames != null && ndviFileNames.Length != 1)
            {
                NDVIBandCH = 1;
            }
            string NDVIBackFile = _curArguments.GetArg("NDVIBackFile").ToString();
            string LSTFile      = lstFileNames == null || lstFileNames.Length == 1 ? _curArguments.GetArg("LSTFile").ToString() : MAxValue(lstFileNames, LSTBandCH, (float)LSTZoom);

            if (lstFileNames != null && lstFileNames.Length != 1)
            {
                LSTBandCH = 1;
            }
            string LSTBackFile = _curArguments.GetArg("LSTBackFile").ToString();

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("NDVIFile", new FilePrdMap(NDVIFile, NDVIZoom, new VaildPra(ndviVaildMin, ndviVaildMax), new int[] { NDVIBandCH }));
            filePrdMap.Add("NDVIBackFile", new FilePrdMap(NDVIBackFile, NDVIBackZoom, new VaildPra(ndviVaildMin, ndviVaildMax), new int[] { NDVIBackBandMinCH, NDVIBackBandMaxCH }));
            filePrdMap.Add("LSTFile", new FilePrdMap(LSTFile, LSTZoom, new VaildPra(lstVaildMin, lstVaildMax), new int[] { LSTBandCH }));
            filePrdMap.Add("LSTBackFile", new FilePrdMap(LSTBackFile, LSTBackZoom, new VaildPra(lstVaildMin, lstVaildMax), new int[] { LSTBackBandMinCH, LSTBackBandMaxCH }));

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            IVirtualRasterDataProvider vrd     = null;

            try
            {
                vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
                if (vrd == null)
                {
                    throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
                }
                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                IPixelFeatureMapper <Int16> result    = new MemPixelFeatureMapper <Int16>("0VTI", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                float vci = 0f;
                float tci = 0f;
                rpVisitor.VisitPixel(new int[] { filePrdMap["NDVIFile"].StartBand,
                                                 filePrdMap["NDVIBackFile"].StartBand,
                                                 filePrdMap["NDVIBackFile"].StartBand + 1,
                                                 filePrdMap["LSTFile"].StartBand,
                                                 filePrdMap["LSTBackFile"].StartBand,
                                                 filePrdMap["LSTBackFile"].StartBand + 1 },
                                     (index, values) =>
                {
                    if (values[0] < filePrdMap["NDVIFile"].VaildValue.Min || values[0] > filePrdMap["NDVIFile"].VaildValue.Max ||
                        values[1] < filePrdMap["NDVIBackFile"].VaildValue.Min || values[1] > filePrdMap["NDVIBackFile"].VaildValue.Max ||
                        values[2] < filePrdMap["NDVIBackFile"].VaildValue.Min || values[2] > filePrdMap["NDVIBackFile"].VaildValue.Max ||
                        values[3] < filePrdMap["LSTFile"].VaildValue.Min || values[3] > filePrdMap["LSTFile"].VaildValue.Max ||
                        values[4] < filePrdMap["LSTBackFile"].VaildValue.Min || values[4] > filePrdMap["LSTBackFile"].VaildValue.Max ||
                        values[5] < filePrdMap["LSTBackFile"].VaildValue.Min || values[5] > filePrdMap["LSTBackFile"].VaildValue.Max)
                    {
                        result.Put(index, 0);
                    }
                    else
                    {
                        //计算VCI
                        vci = (values[0] - values[1]) / (values[2] - values[1]);
                        //计算TCI
                        tci = (values[3] - values[4]) / (values[5] - values[4]);
                        result.Put(index, (Int16)((0.5 * vci + 0.5 * tci) * VTIZoom));
                    }
                });
                return(result);
            }
            finally
            {
                if (vrd != null)
                {
                    vrd.Dispose();
                }
            }
        }
コード例 #7
0
 public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
 {
     _contextMessage = contextMessage;
     if (_argumentProvider != null)
     {
         _curArguments = _argumentProvider;
     }
     if (_curArguments == null)
     {
         return(null);
     }
     if (_curArguments.GetArg("AlgorithmName") == null)
     {
         PrintInfo("参数\"AlgorithmName\"为空。");
         return(null);
     }
     if (_curArguments.GetArg("AlgorithmName").ToString() == "CLMAlgorithm")
     {
         return(CLMAlgorithm());
     }
     //蓝藻云判识入口,其他采用统一方法
     if (_curArguments.GetArg("AlgorithmName").ToString() == "BAGCLMAlgorithm")
     {
         return(BAGAlgorithm());
     }
     else
     {
         PrintInfo("指定的算法没有实现。");
         return(null);
     }
 }
コード例 #8
0
        private void TrySetInstanceArgs()
        {
            _instanceDef = TryGetInstanceFromOutFileIdentify();
            if (_instanceDef == null)
            {
                return;
            }
            IArgumentProvider argumentProvider = _activeMonitoringSubProduct.ArgumentProvider;
            bool   isSpecifyFiles = false;
            object obj            = argumentProvider.GetArg("isSpecifyFiles");

            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
            {
                isSpecifyFiles = bool.Parse(obj.ToString());
            }
            string fileProvider = _instanceDef.FileProvider;

            string[] fps = fileProvider.Split(':');
            if (fps == null || fps.Length != 2)
            {
                return;
            }
            string key          = fps[0];
            string needIdentify = fps[1];

            if (key == "ContextEnvironment")
            {
                if (needIdentify == "CurrentRasterFile")    //多通道合成图,当前区域
                {
                    //(_currentCanvasViewer.ActiveDrawing as RasterDrawing).DataProvider;
                }
                else
                {
                    if (!isSpecifyFiles)
                    {
                        IWorkspace wks = Workspace;
                        if (wks == null)
                        {
                            return;
                        }

                        string[] selectedFiles = null;
                        if (wks.ActiveCatalog != null)
                        {
                            selectedFiles = wks.ActiveCatalog.GetSelectedFiles(needIdentify);
                        }
                        if (selectedFiles == null)
                        {
                            ICatalog cat = wks.GetCatalogByIdentify(needIdentify);
                            if (cat != null)
                            {
                                selectedFiles = cat.GetSelectedFiles(needIdentify);
                            }
                        }
                        _selectedFiles = selectedFiles;
                        if (selectedFiles != null)
                        {
                            argumentProvider.SetArg("SelectedPrimaryFiles", selectedFiles);
                        }
                    }
                }
            }

            //IEnvironmentVarProvider varPrd = argumentProvider.EnvironmentVarProvider;
        }
コード例 #9
0
ファイル: CreateArgument.cs プロジェクト: windygu/hispeed
        public static BackTmpComputer CreateBackTmpComputer(IArgumentProvider argProvider, IBackTmpComputerHelper helper, IContextMessage contextMessage)
        {
            int             minWndSize                    = Obj2Int(argProvider.GetArg("BackWndMin"));
            int             maxWndSize                    = Obj2Int(argProvider.GetArg("BackWndMax"));
            int             localBackTmpMax               = Obj2Int(argProvider.GetArg("BackTmp_localBackTmpMax"));
            int             localBackTmpMin               = Obj2Int(argProvider.GetArg("BackTmp_localBackTmpMin"));
            int             glaringVIRR                   = Obj2Int(argProvider.GetArg("BackTmp_GlaringVIRR"));
            int             wildernessCorrect             = Obj2Int(argProvider.GetArg("BackTmp_WildernessCorrect"));
            int             maxHitedPixelCount            = Obj2Int(argProvider.GetArg("BackTmp_SkyPixelCount"));
            IBandNameRaster bandNameRaster                = argProvider.DataProvider as IBandNameRaster;
            int             visBandNo                     = TryGetBandNo(argProvider, bandNameRaster, "Visible");
            int             nearIfrBandNo                 = TryGetBandNo(argProvider, bandNameRaster, "NearInfrared");
            int             midIfrBandNo                  = TryGetBandNo(argProvider, bandNameRaster, "MiddleInfrared");
            int             farIfrBandNo                  = TryGetBandNo(argProvider, bandNameRaster, "FarInfrared");
            float           fireGradeLevel1               = Obj2Float(argProvider.GetArg("Intensity_Grade1"));
            float           fireGradeLevel2               = Obj2Float(argProvider.GetArg("Intensity_Grade2"));
            float           fireGradeLevel3               = Obj2Float(argProvider.GetArg("Intensity_Grade3"));
            float           fireGradeLevel4               = Obj2Float(argProvider.GetArg("Intensity_Grade4"));
            float           fireGradeLevel5               = Obj2Float(argProvider.GetArg("Intensity_Grade5"));
            float           vis_FirReliability            = Obj2Float(argProvider.GetArg("Vis_FirReliability"));
            float           midIfr_farInfr_FirReliability = Obj2Float(argProvider.GetArg("MidIfr_farInfr_FirReliability"));
            float           midIfr_FirReliability         = Obj2Float(argProvider.GetArg("MidIfr_FirReliability"));
            bool            isNight = bool.Parse(argProvider.GetArg("IsNight").ToString());

            if (!isNight && (visBandNo < 1 || midIfrBandNo < 1 || farIfrBandNo < 1 || nearIfrBandNo < 1))
            {
                PrintInfo(contextMessage, "     获取波段序号(可见光、近红外、中红外、远红外)时发生错误。");
                return(null);
            }
            else if (isNight && (farIfrBandNo < 1 || midIfrBandNo < 1))
            {
                PrintInfo(contextMessage, "     获取波段序号(可见光、近红外、中红外、远红外)时发生错误。");
                return(null);
            }
            float bandZoom = Obj2Float(argProvider.GetArg("MiddleInfrared_Zoom"));

            if (bandZoom < float.Epsilon)
            {
                PrintInfo(contextMessage, "     波段数值缩放参数设置错误,使用缺省值1。");
            }
            ISolarZenithProvider solarZentihProvider = null;
            float minSolarZentih = Obj2Float(argProvider.GetArg("BackTmp_SolarAzimuthMin"));
            float maxSolarZentih = Obj2Float(argProvider.GetArg("BackTmp_SolarAzimuthMax"));
            //亚像元面积计算
            float midIfrCenterWaveNum = Obj2Float(argProvider.GetArg("MiddleInfrared_CenterWaveNum"));
            float farIfrCenterWaveNum = Obj2Float(argProvider.GetArg("FarInfrared_CenterWaveNum"));

            TryCorrectCenterWaveNum(argProvider.DataProvider, midIfrBandNo, farIfrBandNo, ref midIfrCenterWaveNum, ref farIfrCenterWaveNum, contextMessage);
            if (midIfrCenterWaveNum < float.Epsilon || farIfrCenterWaveNum < float.Epsilon)
            {
                PrintInfo(contextMessage, "     获取中红外、远红外中心波数失败,忽略亚像元面积、火点强度计算。");
            }
            int   midIfrMaxMidIfrValue = Obj2Int(argProvider.GetArg("BackTmp_MaxMidIfrValue"));
            float firComputeFactor     = Obj2Float(argProvider.GetArg("BackTmp_FirComputeFactor"));
            float firIntensityFactor   = Obj2Float(argProvider.GetArg("BackTmp_FirIntensityFactor"));

            //
            return(new BackTmpComputer(minWndSize, maxWndSize,
                                       maxHitedPixelCount, solarZentihProvider, minSolarZentih, maxSolarZentih,
                                       farIfrBandNo, midIfrBandNo, visBandNo, nearIfrBandNo, bandZoom,
                                       midIfrCenterWaveNum, farIfrCenterWaveNum,
                                       midIfrMaxMidIfrValue, firComputeFactor, firIntensityFactor,
                                       localBackTmpMax, localBackTmpMin, glaringVIRR, wildernessCorrect, helper,
                                       fireGradeLevel1, fireGradeLevel2, fireGradeLevel3, fireGradeLevel4, fireGradeLevel5,
                                       vis_FirReliability, midIfr_farInfr_FirReliability, midIfr_FirReliability));
        }
コード例 #10
0
ファイル: CreateArgument.cs プロジェクト: windygu/hispeed
        public static ICandidatePixelFilter CreateAbnormalHighTmpFile(IArgumentProvider argProvider, IContextMessage contextMessage)
        {
            float bandZoom = Obj2Float(argProvider.GetArg("MiddleInfrared_Zoom"));

            if (bandZoom < float.Epsilon)
            {
                PrintInfo(contextMessage, "     中红外波段数值缩放参数设置错误。");
                return(null);
            }
            IBandNameRaster bandNameRaster    = argProvider.DataProvider as IBandNameRaster;
            int             midInfraredBandNo = TryGetBandNo(argProvider, bandNameRaster, "MiddleInfrared");

            if (midInfraredBandNo < 1)
            {
                PrintInfo(contextMessage, "     无法正确获取中红外波段序号。");
                return(null);
            }
            int farInfraredBandNo = TryGetBandNo(argProvider, bandNameRaster, "FarInfrared");

            if (farInfraredBandNo < 1)
            {
                PrintInfo(contextMessage, "     无法正确获取远红外波段序号。");
                return(null);
            }
            int maxWndSize = Obj2Int(argProvider.GetArg("HTWndMax"));

            if (maxWndSize < 7)
            {
                PrintInfo(contextMessage, "     未能获取正确的最大邻域窗口大小,设置为默认值7。");
                maxWndSize = 7;
            }
            int minWndSize     = 7;
            int midInfraredMax = Obj2Int(argProvider.GetArg("HTMiddleInfraredMax"));

            if (midInfraredMax == 0)
            {
                PrintInfo(contextMessage, "     中红外最大值参数设置错误。");
                return(null);
            }
            int dlt_mid_far = Obj2Int(argProvider.GetArg("HTMiddleFarInfraredDiff"));

            if (dlt_mid_far == 0)
            {
                PrintInfo(contextMessage, "     (中红外 - 远红外)差值阈值设置错误。");
                return(null);
            }
            int mid_offset = Obj2Int(argProvider.GetArg("HTMiddleInfraredOffset"));

            if (mid_offset == 0)
            {
                PrintInfo(contextMessage, "     中红外偏移阈值设置错误。");
                return(null);
            }
            int abnormalPixelCount = Obj2Int(argProvider.GetArg("HTAbnormalPixelCount"));

            if (abnormalPixelCount == 0)
            {
                PrintInfo(contextMessage, "     邻域内异常高温点数量阈值设置错误,设为默认值6。");
                abnormalPixelCount = 6;
            }
            AbnormalHTmpPixelFilter filter = new AbnormalHTmpPixelFilter(minWndSize,
                                                                         maxWndSize, midInfraredBandNo, farInfraredBandNo, bandZoom,
                                                                         mid_offset,
                                                                         midInfraredMax,
                                                                         dlt_mid_far,
                                                                         abnormalPixelCount,
                                                                         argProvider);

            return(filter);
        }
コード例 #11
0
ファイル: CreateArgument.cs プロジェクト: windygu/hispeed
        public static DoubtFirPixelFilter CreateDoubtFilter(IArgumentProvider argProvider, IContextMessage contextMessage)
        {
            int             minWndSize     = Obj2Int(argProvider.GetArg("BackWndMin"));
            int             maxWndSize     = Obj2Int(argProvider.GetArg("BackWndMax"));
            IBandNameRaster bandNameRaster = argProvider.DataProvider as IBandNameRaster;
            int             visBandNo      = TryGetBandNo(argProvider, bandNameRaster, "Visible");
            int             nearIfrBandNo  = TryGetBandNo(argProvider, bandNameRaster, "NearInfrared");
            int             midIfrBandNo   = TryGetBandNo(argProvider, bandNameRaster, "MiddleInfrared");
            int             farIfrBandNo   = TryGetBandNo(argProvider, bandNameRaster, "FarInfrared");
            bool            isNight        = bool.Parse(argProvider.GetArg("IsNight").ToString());

            if (!isNight && (visBandNo < 1 || midIfrBandNo < 1 || farIfrBandNo < 1 || nearIfrBandNo < 1))
            {
                PrintInfo(contextMessage, "     获取波段序号(可见光、近红外、中红外、远红外)时发生错误。");
                return(null);
            }
            else if (isNight && (farIfrBandNo < 1 || midIfrBandNo < 1))
            {
                PrintInfo(contextMessage, "     获取波段序号(可见光、近红外、中红外、远红外)时发生错误。");
                return(null);
            }
            float bandZoom        = Obj2Float(argProvider.GetArg("MiddleInfrared_Zoom"));
            int   hitedPixelCount = Obj2Int(argProvider.GetArg("HitedPixelCount"));
            ISolarZenithProvider solarZentihProvider = null;
            float minSolarZentih = Obj2Float(argProvider.GetArg("BackTSolarZenith"));

            if (bandZoom < float.Epsilon)
            {
                PrintInfo(contextMessage, "     波段数值缩放参数设置错误,使用缺省值1。");
            }
            //water
            int minMidInfraredValue_water       = Obj2Int(argProvider.GetArg("Water_MinMidIfr"));
            int minNearInfraredValue_water      = Obj2Int(argProvider.GetArg("Water_MinNearIfr"));
            int nearInfrared_visibleValue_water = Obj2Int(argProvider.GetArg("Water_NearIfr_Vis"));
            //cloud
            int minVisibleValue_cloud  = Obj2Int(argProvider.GetArg("Cloud_MinVis"));
            int farInfraredValue_cloud = Obj2Int(argProvider.GetArg("Cloud_FarIfr"));
            //doubt
            int midInfraredValue_DoubtFir        = Obj2Int(argProvider.GetArg("Doubt_MidIfr"));
            int dltMidInfraredValue_DoubtFir     = Obj2Int(argProvider.GetArg("Doubt_MidIfr_Diff"));
            int midInfrared_farInfrared_DoubtFir = Obj2Int(argProvider.GetArg("Doubt_MidIfr_FarIfr"));
            int minMidInfraredValue_DoubtFir     = Obj2Int(argProvider.GetArg("Doubt_MinMidIfr"));
            int maxHTmpPixelCount_DoubtFir       = Obj2Int(argProvider.GetArg("Doubt_MaxHTmpPixelCount"));
            int midInfraredAvg_DoubtFir          = Obj2Int(argProvider.GetArg("Doubt_MidIfrAvg"));
            //
            DoubtFirPixelFilter filter = new DoubtFirPixelFilter
                                         (
                //wnd size
                minWndSize, maxWndSize,
                //bandNo
                farIfrBandNo, midIfrBandNo, nearIfrBandNo, visBandNo,
                //zoom
                bandZoom,
                solarZentihProvider,
                //
                hitedPixelCount,
                minSolarZentih,
                //water
                minMidInfraredValue_water,
                minNearInfraredValue_water,
                nearInfrared_visibleValue_water,
                //cloud
                minVisibleValue_cloud,
                farInfraredValue_cloud,
                //doubt fir
                midInfraredValue_DoubtFir,
                dltMidInfraredValue_DoubtFir,
                midInfrared_farInfrared_DoubtFir,
                minMidInfraredValue_DoubtFir,
                maxHTmpPixelCount_DoubtFir,
                midInfraredAvg_DoubtFir
                                         );

            return(filter);
        }
コード例 #12
0
ファイル: SubProductSWIDRT.cs プロジェクト: windygu/hispeed
        private IExtractResult DemAlgorithm()
        {
            int    DNTBandCH   = (int)_curArguments.GetArg("DNTBand");
            double DNTZoom     = (float)_curArguments.GetArg("DNTZoom");
            float  DNTVaildMin = (float)_curArguments.GetArg("DNTVaildMin");
            float  DNTVaildMax = (float)_curArguments.GetArg("DNTVaildMax");

            Int16 DemMin     = (Int16)_curArguments.GetArg("DemMin");
            float DemCorrect = (float)_curArguments.GetArg("DemCorrect");

            double SWIZoom = (float)_curArguments.GetArg("SWIZoom");
            DRTExpCoefficientCollection ExpCoefficient = _curArguments.GetArg("ExpCoefficient") as DRTExpCoefficientCollection;
            string errorStr = null;

            if (DNTBandCH == -1 || _curArguments.GetArg("DNTFile") == null || _curArguments.GetArg("DemFile") == null || ExpCoefficient == null)
            {
                errorStr = "SWI生产所用文件或通道未设置完全,请检查!";
                return(null);
            }
            string DNTFile = _curArguments.GetArg("DNTFile").ToString();
            string DemFile = _curArguments.GetArg("DemFile").ToString();

            if (string.IsNullOrEmpty(ExpCoefficient.EgdesFilename) || !File.Exists(ExpCoefficient.EgdesFilename))
            {
                string fileanme = AppDomain.CurrentDomain.BaseDirectory + @"\SystemData\RasterTemplate\\China_Province.dat";
                if (File.Exists(fileanme))
                {
                    ExpCoefficient.EgdesFilename = fileanme;
                }
                else
                {
                    errorStr = "SWI生产所用的经验系数边界文件不存在,请检查!";
                    return(null);
                }
            }
            ;
            string EdgesFile = ExpCoefficient.EgdesFilename;

            Dictionary <string, FilePrdMap> filePrdMap = new Dictionary <string, FilePrdMap>();

            filePrdMap.Add("DNTFile", new FilePrdMap(DNTFile, DNTZoom, new VaildPra(DNTVaildMin, DNTVaildMax), new int[] { DNTBandCH }));
            filePrdMap.Add("DemFile", new FilePrdMap(DemFile, 1, new VaildPra(DemMin, float.MaxValue), new int[] { 1 }));
            filePrdMap.Add("EdgesFile", new FilePrdMap(EdgesFile, 1, new VaildPra(float.MinValue, float.MaxValue), new int[] { 1 }));

            ITryCreateVirtualPrd       tryVPrd = new TryCreateVirtualPrdByMultiFile();
            DRTExpCoefficientItem      item    = null;
            IVirtualRasterDataProvider vrd     = null;

            try
            {
                vrd = tryVPrd.CreateVirtualRasterPRD(ref filePrdMap);
                if (vrd == null)
                {
                    throw new Exception("数据间无相交部分,无法创建虚拟数据提供者!");
                }
                ArgumentProvider            ap        = new ArgumentProvider(vrd, null);
                RasterPixelsVisitor <float> rpVisitor = new RasterPixelsVisitor <float>(ap);
                IPixelFeatureMapper <Int16> result    = new MemPixelFeatureMapper <Int16>("0SWI", 1000, new Size(vrd.Width, vrd.Height), vrd.CoordEnvelope, vrd.SpatialRef);
                double swiTemp = 0f;
                rpVisitor.VisitPixel(new int[] { filePrdMap["DNTFile"].StartBand,
                                                 filePrdMap["DemFile"].StartBand,
                                                 filePrdMap["EdgesFile"].StartBand },
                                     (index, values) =>
                {
                    if (values[0] < filePrdMap["DNTFile"].VaildValue.Min || values[0] > filePrdMap["DNTFile"].VaildValue.Max)
                    {
                        result.Put(index, 0);
                    }
                    else
                    {
                        item = ExpCoefficient.GetExpItemByNum((int)values[2]);
                        if (item == null)
                        {
                            result.Put(index, 0);
                        }
                        else
                        {
                            //计算SWI
                            swiTemp = item.APara * values[0] + item.BPara + item.CPara;
                            if (values[1] > filePrdMap["DemFile"].VaildValue.Min)
                            {
                                swiTemp += DemCorrect;
                            }
                            result.Put(index, (Int16)(swiTemp * SWIZoom));
                        }
                    }
                });
                return(result);
            }
            finally
            {
                if (vrd != null)
                {
                    vrd.Dispose();
                }
            }
        }
コード例 #13
0
        public Dictionary <string, Dictionary <string, StatInfoBase[]> > GetStatInfo(SubProductDef subProductDef, IArgumentProvider argProvider, Action <int, string> progressTracker)
        {
            _subProductDef    = subProductDef;
            _argumentProvider = argProvider;
            if (argProvider == null)
            {
                return(null);
            }
            string[] filenames = GetStringArray("SelectedPrimaryFiles");
            if (filenames == null || filenames.Length == 0)
            {
                return(null);
            }
            StatDimClass dimClass = argProvider.GetArg("StatDim") == null ? null : argProvider.GetArg("StatDim") as StatDimClass;

            if (dimClass == null)
            {
                return(null);
            }
            enumStatDimType       dimType       = dimClass.DimType;
            enumStatDayMosaicType dayMosaicType = dimClass.DayMosaicType;
            Dictionary <string, Dictionary <string, StatInfoBase[]> > result = new Dictionary <string, Dictionary <string, StatInfoBase[]> >();
            RasterIdentify rid      = null;
            StatInfoBase   statInfo = null;
            string         key      = string.Empty;

            if (progressTracker != null)
            {
                progressTracker.Invoke(10, "开始进行长序列面积统计,请稍后...");
            }
            float interval  = (80f / filenames.Length);
            int   fileIndex = 0;

            foreach (string file in filenames)
            {
                if (progressTracker != null)
                {
                    progressTracker.Invoke((int)(++fileIndex * interval) + 10, "开始进行第[" + fileIndex + "]个文件面积统计,请稍后...");
                }
                if (string.IsNullOrEmpty(file) || !File.Exists(file))
                {
                    continue;
                }
                rid = new RasterIdentify(file);
                if (rid == null)
                {
                    continue;
                }
                statInfo = new StatInfoBase(rid.OrbitDateTime.ToString("yyyyMMddHHmmss"), file);
                switch (dimType)
                {
                case enumStatDimType.区分:
                    key = "不区分";
                    break;

                case enumStatDimType.年:
                    key = rid.OrbitDateTime.ToString("yyyy年");
                    break;

                case enumStatDimType.季:
                    key = GetSeason(rid.OrbitDateTime.ToString("yyyy年"), rid.OrbitDateTime.Month);
                    break;

                case enumStatDimType.月:
                    key = rid.OrbitDateTime.ToString("yyyy年MM月");
                    break;

                case enumStatDimType.旬:
                    key = GetTenDays(rid.OrbitDateTime.ToString("yyyy年MM月"), rid.OrbitDateTime.Day);
                    break;

                case enumStatDimType.日:
                    key = rid.OrbitDateTime.ToString("yyyy年MM月dd日");
                    break;

                default:
                    break;
                }
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }
                if (!result.ContainsKey(key))
                {
                    Dictionary <string, StatInfoBase[]> tempInfo = GetDayInfo(file, rid.OrbitDateTime.ToString("yyyyMMdd"), new Dictionary <string, StatInfoBase[]>(), ref statInfo, argProvider, progressTracker);
                    if (tempInfo != null && tempInfo.Count != 0)
                    {
                        result.Add(key, tempInfo);
                    }
                }
                else
                {
                    Dictionary <string, StatInfoBase[]> tempInfo = GetDayInfo(file, rid.OrbitDateTime.ToString("yyyyMMdd"), result[key], ref statInfo, argProvider, progressTracker);
                    if (tempInfo != null && tempInfo.Count != 0)
                    {
                        result[key] = tempInfo;
                    }
                }
            }
            return(result.Count == 0 ? null : result);
        }
コード例 #14
0
        private bool ArgsIsFull()
        {
            if (_argumentProvider == null)
            {
                _error = "未提供[" + _subProductDef.Name + "]子产品参数提供者.";
                return(false);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                _error = "未提供[" + _subProductDef.Name + "]子产品所用算法名.";
                return(false);
            }
            string       algorithmName = _argumentProvider.GetArg("AlgorithmName").ToString();
            AlgorithmDef algorithmDef  = _subProductDef.GetAlgorithmDefByIdentify(algorithmName);

            if (algorithmDef == null)
            {
                _error = "当前[" + _subProductDef.Name + "]子产品不包含\"" + algorithmName + "\"算法.";
                return(false);
            }
            if (algorithmDef != null)
            {
                object bandArg = null;
                foreach (BandDef arg in algorithmDef.Bands)
                {
                    bandArg = _argumentProvider.GetArg(arg.Identify);
                    if (bandArg == null)
                    {
                        _error = "未提供波段[" + arg.Identify + "]信息.";
                        return(false);
                    }
                    if (bandArg.ToString() == "-1")
                    {
                        _error = "波段[" + arg.Identify + "]未找到对应的波段映射.";
                        return(false);
                    }
                }
            }
            ArgumentPair argPair = null;
            ArgumentDef  argDef  = null;

            foreach (ArgumentBase arg in algorithmDef.Arguments)
            {
                if (arg is ArgumentPair)
                {
                    argPair = arg as ArgumentPair;
                    if (argPair.ArgumentMax != null && _argumentProvider.GetArg(argPair.ArgumentMax.Name) == null)
                    {
                        _error = "参数[" + argPair.ArgumentMax.Name + "]未提供.";
                        return(false);
                    }
                    if (argPair.ArgumentMin != null && _argumentProvider.GetArg(argPair.ArgumentMin.Name) == null)
                    {
                        _error = "参数[" + argPair.ArgumentMin.Name + "]未提供.";
                        return(false);
                    }
                }
                else if (arg is ArgumentDef)
                {
                    argDef = arg as ArgumentDef;
                    if (_argumentProvider.GetArg(argDef.Name) == null)
                    {
                        _error = "参数[" + argDef.Name + "]未提供.";
                        return(false);
                    }

                    if (argDef.RefType == "file")
                    {
                        string filename = _argumentProvider.GetArg(argDef.Name).ToString();
                        if (!File.Exists(filename))
                        {
                            _error = "参数文件[" + Path.GetFileName(filename) + "]不存在.";
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #15
0
        private string ComputeBackgroudImage(Action <int, string> processTracker)
        {
            List <string> computeFiles = new List <string>();

            foreach (FileItem item in listBox1.Items)
            {
                computeFiles.Add(item.FileName);
            }
            if (computeFiles == null || computeFiles.Count < 1)
            {
                return(null);
            }
            foreach (string item in computeFiles)
            {
                if (!File.Exists(item))
                {
                    MessageBox.Show("所选择的数据:\"" + item + "\"不存在。");
                    return(null);
                }
            }
            IArgumentProvider argPrd = Tag as IArgumentProvider;

            if (argPrd == null)
            {
                return(null);
            }
            int visiNo = (int)argPrd.GetArg("Visible");
            int midNo2 = (int)argPrd.GetArg("MiddleInfrared2");
            int farNo1 = (int)argPrd.GetArg("FarInfrared11");
            int farNo2 = (int)argPrd.GetArg("FarInfrared12");

            int[] bandNos          = new int[] { farNo1, farNo2, midNo2, visiNo };
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                for (int i = 0; i < computeFiles.Count; i++)
                {
                    IRasterDataProvider inRaster = RasterDataDriver.Open(computeFiles[i]) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNos.Length)
                    {
                        MessageBox.Show("请选择正确的数据进行背景亮温计算。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, bandNos);
                    rms.Add(rm);
                }
                //输出文件准备(作为输入栅格并集处理)
                RasterIdentify ri          = new RasterIdentify(_dataProvider.fileName);
                string         outFileName = MifEnvironment.GetFullFileName(Path.GetFileName(ri.ToWksFullFileName(".ldf")));
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, bandNos.Length))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns    = rms.ToArray();
                    List <int>    bandNoList = new List <int>();
                    for (int i = 1; i <= bandNos.Length; i++)
                    {
                        bandNoList.Add(i);
                    }
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, bandNoList.ToArray()) };
                    //创建处理模型
                    RasterProcessModel <short, short> rfr = null;
                    rfr = new RasterProcessModel <short, short>(null);
                    rfr.SetRaster(fileIns, fileOuts);
                    rfr.RegisterCalcModel(new RasterCalcHandler <short, short>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        for (int j = 0; j < rvInVistor.Length; j++)
                        {
                            for (int i = 0; i < bandNos.Length; i++)
                            {
                                short[] dt = rvInVistor[j].RasterBandsData[i];
                                if (dt != null)
                                {
                                    for (int index = 0; index < dt.Length; index++)
                                    {
                                        if (dt[index] > rvOutVistor[0].RasterBandsData[i][index])
                                        {
                                            rvOutVistor[0].RasterBandsData[i][index] = dt[index];
                                        }
                                    }
                                }
                            }
                        }
                    }));
                    //执行
                    rfr.Excute();
                    return(outFileName);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }
        }
コード例 #16
0
ファイル: BackTmpComputer.cs プロジェクト: windygu/hispeed
        /// <summary>
        /// 夜间火背景计算
        /// </summary>
        /// <param name="argProvider"></param>
        /// <param name="aoiRect"></param>
        /// <param name="aoi"></param>
        /// <returns></returns>
        public Dictionary <int, PixelFeature> ComputeNight(IArgumentProvider argProvider, Rectangle aoiRect, int[] aoi)
        {
            _width   = argProvider.DataProvider.Width;
            _maxLat  = argProvider.DataProvider.CoordEnvelope.MaxY;
            _res     = argProvider.DataProvider.ResolutionY;
            _isNight = bool.Parse(argProvider.GetArg("IsNight").ToString());
            CreateAndInitFeatures(aoi);
            int tempIndex = 0;

            using (IRasterPixelsVisitor <UInt16> visitor = new RasterPixelsVisitor <UInt16>(argProvider))
            {
                //邻域内符合条件的像元个数
                int   preHitedPixelCount = 0;
                int   preWndSize         = 0;
                int[] bandNos            = new int[] { _midIfrBandNo, _farIfrBandNo };
                _midIfrBandIdx = 0;
                _farIfrBandIdx = 1;
                //
                int[] hitedIndexes = new int[100 * 100]; //最大窗口100
                //
                //by chennan 20140423 处理当当前窗口被恢复成最小窗口时,将晴空像元个数、索引更改回最小窗口状态
                int        preHitedPixelCountSave = 0;
                List <int> hitedIndexesSave       = new List <int>();
                //
                visitor.VisitPixelWnd(aoiRect, aoi, bandNos, bandNos, _minWndSize, _maxWndSize,
                                      (pixelIdx, crtWndSize, bandValues, wndValues) =>
                {
                    if (preWndSize != crtWndSize)
                    {
                        preHitedPixelCount = 0;
                        preWndSize         = crtWndSize;
                    }
                    _cloudCount        = 0;
                    preHitedPixelCount = GetNightHitedPixelCount(pixelIdx, bandValues, wndValues, hitedIndexes);
                    //by chennan 20140423 处理当当前窗口被恢复成最小窗口时,将晴空像元个数、索引更改回最小窗口状态
                    //
                    if (crtWndSize == _minWndSize)
                    {
                        preHitedPixelCountSave = preHitedPixelCount;
                        hitedIndexesSave.AddRange(hitedIndexes);
                    }
                    //
                    return(preHitedPixelCount < _maxHitedPixelCount && crtWndSize < _maxWndSize);
                },
                                      (pixelIdx, crtWndSize, bandValues, wndValues) =>
                {
                    if (preHitedPixelCount >= _maxHitedPixelCount)
                    {
                        //by chennan 20140423 处理当当前窗口被恢复成最小窗口时,将晴空像元个数、索引更改回最小窗口状态
                        //
                        if (crtWndSize == _minWndSize)
                        {
                            preHitedPixelCount = preHitedPixelCountSave;
                            hitedIndexes       = hitedIndexesSave.ToArray();
                        }
                        //
                        Compute(preHitedPixelCount, pixelIdx, bandValues, wndValues, hitedIndexes);
                    }
                    else
                    {
                        int row    = pixelIdx / _width;
                        int col    = pixelIdx % _width;
                        int length = crtWndSize / 2;
                        for (int i = row - length; i <= row + length; i++)
                        {
                            if (i < 0)
                            {
                                continue;
                            }
                            for (int j = col - length; j <= col + length; j++)
                            {
                                tempIndex = i * _width + j;
                                if (_featrueIndex.Contains(tempIndex))
                                {
                                    _features[pixelIdx] = _features[tempIndex];
                                }
                            }
                        }
                    }
                    preHitedPixelCountSave = 0;
                    hitedIndexesSave.Clear();
                });
            }
            return(_features);
        }