Beispiel #1
0
        public unsafe IExtractResult Do(string productIdentify, string subProductIdentify, IRasterDataProvider dataProvider, string filename, out string error)
        {
            error = string.Empty;
            if (!CanDo(productIdentify, subProductIdentify, filename, out error))
            {
                return(null);
            }
            if (_transDef == null)
            {
                _transDef = (new MVGXMLParser()).GetTransDef();
            }
            ProductDef       product    = _transDef.GetProductBySmartProductIdentify(productIdentify);
            SubProductDef    subProduct = product.GetSubProductBySmartIdentfy(subProductIdentify);
            IGeoDataProvider provider   = GeoDataDriver.Open(filename, enumDataProviderAccess.ReadOnly, null);

            if (provider != null)
            {
                MvgDataProvider mvgProvider = provider as MvgDataProvider;
                if (mvgProvider == null)
                {
                    error = "MVG转换尚不支持文件【" + Path.GetFileName(filename) + "】!";
                    return(null);
                }
                float  xResolution = dataProvider.ResolutionX, mvgXResolution = (float)mvgProvider.CoordEnvelope.Width / mvgProvider.Width;
                float  yResolution = dataProvider.ResolutionY, mvgYResolution = (float)mvgProvider.CoordEnvelope.Height / mvgProvider.Height;
                int    width = dataProvider.Width, mvgWidth = mvgProvider.Width;
                double minX = dataProvider.CoordEnvelope.MinX, mvgMinX = mvgProvider.CoordEnvelope.MinX;
                double maxY = dataProvider.CoordEnvelope.MaxY, mvgMaxY = mvgProvider.CoordEnvelope.MaxY;
                int    xIndex = 0;
                int    yIndex = 0;
                if (dataProvider.DataType == enumDataType.UInt16)
                {
                    Int16[] dataBlock = new Int16[mvgProvider.Width * mvgProvider.Height];
                    fixed(Int16 *buffer = dataBlock)
                    {
                        IntPtr ptr = new IntPtr(buffer);

                        mvgProvider.Read(0, 0, mvgProvider.Width, mvgProvider.Height, ptr, enumDataType.Int16, mvgProvider.Width, mvgProvider.Height, 1, new int[] { 1 }, enumInterleave.BSQ);
                    }

                    Dictionary <Int16, Int16>    dic     = subProduct.GetTableDic <Int16, Int16>();
                    IPixelIndexMapper            map     = PixelIndexMapperFactory.CreatePixelIndexMapper(productIdentify + "_" + subProductIdentify, width, dataProvider.Height, dataProvider.CoordEnvelope, dataProvider.SpatialRef);
                    RasterPixelsVisitor <UInt16> visitor = new RasterPixelsVisitor <UInt16>(new ArgumentProvider(dataProvider, null));
                    visitor.VisitPixel(new int[] { 1 }, (index, values) =>
                    {
                        xIndex = (int)Math.Round((minX + (index % width * xResolution) - mvgMinX) / mvgXResolution);
                        yIndex = (int)Math.Round((mvgMaxY - (maxY - (index / width * yResolution))) / mvgYResolution);
                        if (xIndex >= 0 && yIndex >= 0 && yIndex * mvgWidth + xIndex < dataBlock.Length)
                        {
                            if (dic.ContainsKey(dataBlock[yIndex * mvgWidth + xIndex]))
                            {
                                map.Put(index);
                            }
                        }
                    });
                    return(map);
                }
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 统计判识结果的面积
        /// </summary>
        /// <param name="dataProvider">判识结果使用的栅格文件</param>
        /// <param name="extractedPixels">判识结果</param>
        /// <param name="aoi"></param>
        /// <param name="filterDic"></param>
        /// <returns></returns>
        public double Area(IRasterDataProvider dataProvider, IPixelIndexMapper extractedPixels, int[] aoi)
        {
            if (dataProvider.CoordEnvelope == null)
            {
                return(0);
            }
            IArgumentProvider argPrd = new ArgumentProvider(dataProvider, null);

            argPrd.AOI = aoi;
            IRasterPixelsVisitor <T> visitor = new RasterPixelsVisitor <T>(argPrd);
            int    row      = 0;
            int    width    = dataProvider.Width;
            double maxLat   = dataProvider.CoordEnvelope.MaxY;
            double res      = dataProvider.ResolutionX;
            double statArea = 0;

            visitor.VisitPixel(new int[] { 1 },
                               (idx, values) =>
            {
                if (extractedPixels.Get(idx))
                {
                    statArea += ComputePixelArea(row, maxLat, res);
                }
            });
            return(statArea);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public override IExtractResult MakeExtProduct(IPixelIndexMapper piexd, Action <int, string> progressTracker)
        {
            object        obj           = _argumentProvider.GetArg("ucAnlysisTool");
            UCAnlysisTool ucAnlysisTool = null;

            if (obj != null)
            {
                ucAnlysisTool = obj as UCAnlysisTool;
            }
            else
            {
                return(null);
            }
            RasterIdentify rid = new RasterIdentify(_argumentProvider.DataProvider.fileName);

            rid.ProductIdentify    = _subProductDef.ProductDef.Identify;
            rid.SubProductIdentify = _subProductDef.Identify;
            string dstfilename = rid.ToWksFullFileName(".txt");

            if (File.Exists(dstfilename))
            {
                File.Delete(dstfilename);
            }
            if (!string.IsNullOrEmpty(ucAnlysisTool.txtInfos.Text))
            {
                File.WriteAllLines(dstfilename, new string[] { ucAnlysisTool.txtInfos.Text }, Encoding.Unicode);
                FileExtractResult resTxt = new FileExtractResult("LST", dstfilename, true);
                resTxt.SetDispaly(false);
                return(resTxt);
            }
            return(null);
        }
        private void btnExcute_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_currentRasterFile) || lstFiles.Items.Count < 1)
            {
                return;
            }
            if (_session == null)
            {
                return;
            }
            ICanvasViewer cv = _session.SmartWindowManager.ActiveCanvasViewer;

            if (cv == null)
            {
                return;
            }
            int[] drawedAOI = cv.AOIProvider.GetIndexes();
            IMonitoringSession    msession          = _session.MonitoringSession as IMonitoringSession;
            IMonitoringSubProduct subProduct        = msession.ActiveMonitoringSubProduct;
            IPixelIndexMapper     pixelMapper       = (_session.MonitoringSession as IMonitoringSession).ExtractingSession.GetBinaryValuesMapper(subProduct.Definition.ProductDef.Identify, subProduct.Definition.Identify);
            IPixelIndexMapper     resultPixelMapper = GenerateHistoryResultByAOI(pixelMapper, drawedAOI);

            if (pixelMapper != null)
            {
                DisplayResultClass.DisplayResult(_session, subProduct, resultPixelMapper, true);
            }
        }
        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);
        }
Beispiel #7
0
 private Dictionary <int, BagFeature> GetDisplayInfo(IPixelIndexMapper result, int visiBandNo, int niBandNo)
 {
     if (_argumentProvider.DataProvider == null)
     {
         return(null);
     }
     try
     {
         Dictionary <int, BagFeature> features   = new Dictionary <int, BagFeature>();
         BagFeature                  tempFeature = null;
         ArgumentProvider            ap          = new ArgumentProvider(_argumentProvider.DataProvider, null);
         RasterPixelsVisitor <Int16> visitor     = new RasterPixelsVisitor <Int16>(ap);
         visitor.VisitPixel(new int[] { visiBandNo, niBandNo },
                            (index, values) =>
         {
             tempFeature      = new BagFeature();
             tempFeature.Ndvi = GetOnePixelNDVI(values[0], values[1]);
             features.Add(index, tempFeature);
         });
         return(features);
     }
     finally
     {
     }
 }
Beispiel #8
0
        public override IExtractResult MakeExtProduct(IPixelIndexMapper piexd, Action <int, string> progressTracker)
        {
            try
            {
                piexd = CalcBackTmp(piexd);
                if (piexd == null || _curFeatures == null || _argumentProvider == null)
                {
                    return(null);
                }

                Dictionary <int, PixelFeature> features = new Dictionary <int, PixelFeature>();
                foreach (int index in piexd.Indexes)
                {
                    if (_curFeatures.ContainsKey(index))
                    {
                        features.Add(index, _curFeatures[index]);
                    }
                }
                if (features.Count == 0)
                {
                    return(null);
                }
                return(GetOtherExtractResult.GetExtractResult(_argumentProvider, features, piexd, null, progressTracker));
            }
            finally
            {
                _curFeatures = null;
            }
        }
Beispiel #9
0
        private void btSeaIceNDSI_Click(object sender, EventArgs e)
        {
            ExtractProductIdentify exPro = new ExtractProductIdentify();

            exPro.ThemeIdentify      = "CMA";
            exPro.ProductIdentify    = "ICE";
            exPro.SubProductIdentify = "DBLV";

            //IArgumentProviderFactory fac = MifEnvironment.ActiveArgumentProviderFactory;
            ThemeDef      theme = MonitoringThemeFactory.GetThemeDefByIdentify("CMA");
            ProductDef    pro   = theme.GetProductDefByIdentify("ICE");
            SubProductDef sub   = pro.GetSubProductDefByIdentify("DBLV");
            AlgorithmDef  alg   = sub.GetAlgorithmDefByIdentify("NDSIAlgorithm_NOAA");

            IArgumentProvider arg = MonitoringThemeFactory.GetArgumentProvider(exPro, "NDSIAlgorithm_NOAA", "FY3A", "VIRR");

            arg.SetArg("NDSIAlgorithm_NOAA", alg);
            IRasterDataProvider prd = GetRasterDataProvider("ICE");

            arg.DataProvider = prd;
            IMonitoringSubProduct bin    = new SubProductBinaryICE(sub);
            IPixelIndexMapper     result = bin.Make(null) as IPixelIndexMapper;
            string saveName = "e:\\seaice1.png";

            CreatBitmap(prd, result.Indexes.ToArray(), saveName);
        }
Beispiel #10
0
 private int[] MergeFirePoints(IPixelIndexMapper result, int[] firePoints, int[] filteredAOI)
 {
     int[] resultIndex = null;
     UpdateFirePoints(ref firePoints);
     if (firePoints == null)
     {
         resultIndex = filteredAOI;
     }
     else
     {
         if (filteredAOI == null)
         {
             result.Put(firePoints);
             resultIndex = firePoints;
         }
         else
         {
             List <int> firePointsArray = new List <int>();
             firePointsArray.AddRange(firePoints);
             List <int> filteredAOIArray = new List <int>();
             filteredAOIArray.AddRange(filteredAOI);
             resultIndex = firePointsArray.Union(filteredAOI).ToArray <int>();
             result.Put(resultIndex);
         }
     }
     return(resultIndex);
 }
Beispiel #11
0
        public void ApplyResult(IPixelIndexMapper dltResult)
        {
            if (dltResult == null)
            {
                return;
            }
            TryExtCursorInfoForFeaturesDisplay(dltResult);
            //
            IArgumentProvider argprd = _currentSubProduct.ArgumentProvider;
            string            name   = GetName(_currentProduct, _currentSubProduct);
            IPixelIndexMapper result = _resultObjects[name].BinaryValues;

            if (argprd != null && argprd.AOI != null)
            {
                result.Remove(argprd.AOI);
                foreach (int idx in dltResult.Indexes)
                {
                    result.Put(idx);
                }
            }
            else
            {
                result.Reset();
                foreach (int idx in dltResult.Indexes)
                {
                    result.Put(idx);
                }
            }
            UpdateLayer(_resultObjects[name]);
            _isUpdated = true;
        }
Beispiel #12
0
        private void MagicWandResult2ExtractReulst(ScanLineSegment[] segs, IRasterDrawing drawing)
        {
            //获取判识结果对象
            string            name   = GetName(_currentProduct, _currentSubProduct);
            IPixelIndexMapper mapper = _resultObjects[name].BinaryValues;
            //计算当前视窗分辨率和缩放比
            double resX   = drawing.Envelope.Width / drawing.Bitmap.Width;
            double resY   = drawing.Envelope.Height / drawing.Bitmap.Height;
            float  scaleX = (float)(resX / drawing.OriginalResolutionX);
            float  scaleY = (float)(resY / (drawing.OriginalEnvelope.Height / drawing.DataProvider.Height));

            //计算当前视窗位图和原始栅格坐标交集
            Core.DrawEngine.CoordEnvelope evp = drawing.Envelope.Intersect(drawing.OriginalEnvelope);

            /*
             * 计算当前视窗位图中有效影像区域
             */
            int bRow = (int)((drawing.Envelope.MaxY - evp.MaxY) / resY);
            int bCol = (int)((evp.MinX - drawing.Envelope.MinX) / resX);
            int eRow = (int)(bRow + evp.Height / resY);
            int eCol = (int)(bCol + evp.Width / resX);

            /*
             * 因为瓦片为中心对齐方式,因此有无效黑边
             * row0,col0为实际数据行相对于全栅格图像的偏移
             */
            int row0 = (int)((1 / scaleY) * (drawing.OriginalEnvelope.MaxY - evp.MaxY) / drawing.OriginalResolutionX);
            int col0 = (int)((1 / scaleX) * (evp.MinX - drawing.OriginalEnvelope.MinX) / drawing.OriginalResolutionX);

            /*
             * 将扫面线转换到原始图像区域
             */
            List <ScanLineSegment> retSegs = new List <ScanLineSegment>();

            for (int i = 0; i < segs.Length; i++)
            {
                //无效黑边行
                if (segs[i].Row < bRow || segs[i].Row >= eRow)
                {
                    continue;
                }
                segs[i].Row = segs[i].Row - bRow + row0;
                //Math.Max,Max.Min去除无效黑边列
                segs[i].BeginCol = Math.Max(segs[i].BeginCol, bCol) - bCol + col0;
                segs[i].EndCol   = Math.Min(segs[i].EndCol, eCol) - bCol + col0;
                retSegs.Add(segs[i]);
            }
            if (retSegs.Count == 0)
            {
                return;
            }
            // by chennan 应用感兴趣区域
            int[] aoi = GetAOI();
            //将扫描线重采样为原始分辨率(1:1)并生成二值图
            IBinaryResampler resampler = new BinaryResampler();

            resampler.Resample(retSegs.ToArray(), scaleX, scaleY, mapper, aoi);
            //更新图层
            UpdateLayer(_resultObjects[name]);
        }
Beispiel #13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            IMonitoringSubProduct subProduct = GetCurrentSubProduct();

            if (subProduct == null)
            {
                return;
            }
            if (!subProduct.Definition.IsNeedCurrentRaster)
            {
                return;
            }
            IWorkspace wks = (_session.MonitoringSession as IMonitoringSession).Workspace;

            (_session.MonitoringSession as IMonitoringSession).ExtractingSession.AddToWorkspace(wks);
            (_session.MonitoringSession as IMonitoringSession).ExtractingSession.Saved();

            //后续产品制作
            IPixelIndexMapper piexd  = (_session.MonitoringSession as IMonitoringSession).ExtractingSession.GetBinaryValuesMapper(subProduct.Definition.ProductDef.Identify, subProduct.Definition.Identify);
            IExtractResult    result = (subProduct).MakeExtProduct(piexd, null);

            if (result == null)
            {
                return;
            }
            if (!(result is IPixelIndexMapper) && !(result is IExtractResultArray))
            {
                _isAutoSave = false;
            }
            DisplayResultClass.DisplayResult(_session, subProduct, result, true);
        }
Beispiel #14
0
        private ResultObject GetResultObject(ICanvasViewer viewer, IMonitoringProduct product, IMonitoringSubProduct subProduct)
        {
            IRasterDataProvider prd          = GetRasterDataProvider(viewer);
            IPixelIndexMapper   binaryValues = GetBinaryValuesMapper(prd, product, subProduct);
            IBinaryBitampLayer  binaryLayer  = GetBinaryLayer(viewer, prd, product, subProduct);

            return(new ResultObject(binaryValues, binaryLayer));
        }
Beispiel #15
0
        //清除所有判识结果
        private void HandleRemoveAll()
        {
            string            name   = GetName(_currentProduct, _currentSubProduct);
            IPixelIndexMapper mapper = _resultObjects[name].BinaryValues;

            mapper.Reset();
            UpdateLayer(_resultObjects[name]);
        }
Beispiel #16
0
        public void ApplyAdsorb(int[] aoi)
        {
            string            name   = GetName(_currentProduct, _currentSubProduct);
            IPixelIndexMapper result = _resultObjects[name].BinaryValues;

            result.Put(aoi);
            UpdateLayer(_resultObjects[name]);
            _isUpdated = true;
        }
Beispiel #17
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);
            }
        }
Beispiel #18
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);
            }
        }
Beispiel #19
0
        private IPixelIndexMapper DoMake(string express, int[] bandNos, double[] bandZooms)
        {
            IInterestedPixelExtracter extracter = CreateThresholdExtracter(_argumentProvider.DataProvider.DataType);
            Size size = new Size(_argumentProvider.DataProvider.Width, _argumentProvider.DataProvider.Height);
            IPixelIndexMapper result = PixelIndexMapperFactory.CreatePixelIndexMapper("FIR", size.Width, size.Height, _argumentProvider.DataProvider.CoordEnvelope, _argumentProvider.DataProvider.SpatialRef);

            extracter.Reset(_argumentProvider, bandNos, express);
            extracter.Extract(result);
            return(result);
        }
Beispiel #20
0
 private static string WriteInterestedRaster(IPixelIndexMapper result, IRasterDataProvider prd, RasterIdentify rstIdentify, string fname)
 {
     using (IInterestedRaster <Int16> rst = new InterestedRaster <Int16>(rstIdentify,
                                                                         new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone(), prd.SpatialRef))
     {
         rst.Put(result.Indexes.ToArray(), 1);
         fname = rst.FileName;
     }
     return(fname);
 }
Beispiel #21
0
        public string AddToWorkspace(IWorkspace wks)
        {
            if (_currentProduct == null || _currentSubProduct == null || wks == null)
            {
                return(null);
            }
            ICatalog            c      = wks.GetCatalog("CurrentExtracting");
            string              name   = GetName(_currentProduct, _currentSubProduct);
            IPixelIndexMapper   result = _resultObjects[name].BinaryValues;
            IRasterDataProvider prd    = GetRasterDataProvider(_canvasViewer);

            if (prd == null)
            {
                return(null);
            }
            RasterIdentify rstIdentify = GetRasterIdentify(prd);
            string         fname       = InterestedRaster <Int16> .GetWorkspaceFileName(rstIdentify);

            if (File.Exists(fname))
            {
                //GeoDo.RSS.UI.AddIn.Theme.AutoGeneratorSettings.enumActionOfExisted action = GetActionOfFileIsExisted(fname);
                //if (action == AutoGeneratorSettings.enumActionOfExisted.Overide)
                //{
                try
                {
                    fname = WriteInterestedRaster(result, prd, rstIdentify, fname);
                }
                catch (Exception e)
                {
                    MsgBox.ShowError(e.Message);
                }
                //}
                //else if (action == AutoGeneratorSettings.enumActionOfExisted.ReName)
                //{
                //    fname = fname.Replace(".dat", DateTime.Now.ToString("_yyyyMMddHHmmss") + ".dat");
                //    using (IInterestedRaster<Int16> rst = new InterestedRaster<Int16>(fname,
                //        new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone()))
                //    {
                //        rst.Put(result.Indexes.ToArray(), 1);
                //    }
                //}
                //else if (action == AutoGeneratorSettings.enumActionOfExisted.Skip)
                //{
                //}
            }
            else
            {
                fname = WriteInterestedRaster(result, prd, rstIdentify, fname);
            }
            //
            c.AddItem(new CatalogItem(fname, wks.GetCatalogByIdentify(rstIdentify.SubProductIdentify).Definition as SubProductCatalogDef));
            return(fname);
        }
Beispiel #22
0
        private IExtractResult FRILAlgorithm()
        {
            int    VisibleCH        = Obj2Int(_argumentProvider.GetArg("Visible"));
            int    NearInfraredCH   = Obj2Int(_argumentProvider.GetArg("NearInfrared"));
            int    MiddleInfraredCH = Obj2Int(_argumentProvider.GetArg("MiddleInfrared"));
            int    FarInfraredCH    = Obj2Int(_argumentProvider.GetArg("FarInfrared"));
            string currRaster       = Obj2String(_argumentProvider.GetArg("CurrentRasterFile"));
            string currDBLV         = Obj2String(_argumentProvider.GetArg("DBLVFile"));

            if (VisibleCH == -1 || FarInfraredCH == -1 || NearInfraredCH == -1 || MiddleInfraredCH == -1)
            {
                PrintInfo("获取波段序号失败,可能是波段映射表配置错误。");
                return(null);
            }
            if (string.IsNullOrEmpty(currRaster) || string.IsNullOrEmpty(currDBLV))
            {
                PrintInfo("获取算法所用文件失败。");
                return(null);
            }

            List <int>        vertifyIndexiex = null;
            IPixelIndexMapper result          = CreataPixelMapper(currDBLV, out vertifyIndexiex);

            if (result == null || result.Indexes.ToArray().Length == 0)
            {
                PrintInfo("当前判识结果中无火点信息。");
                return(null);
            }
            int[] filteredAOI = result.Indexes.ToArray();
            Size  size        = new Size(_argumentProvider.DataProvider.Width, _argumentProvider.DataProvider.Height);
            DoubtFirPixelFilter doubtFilter = CreateArgument.CreateDoubtFilter(_argumentProvider, _contextMessage);

            if (doubtFilter == null)
            {
                return(null);
            }
            Rectangle aoiRect = AOIHelper.ComputeAOIRect(filteredAOI, size);

            //背景温度计算
            PrintInfo("[开始]背景亮温计算...");
            BackTmpComputer backTmpComputer = CreateArgument.CreateBackTmpComputer(_argumentProvider, doubtFilter as IBackTmpComputerHelper, _contextMessage);

            if (backTmpComputer == null)
            {
                return(null);
            }
            aoiRect = AOIHelper.ComputeAOIRect(filteredAOI, size);
            Dictionary <int, PixelFeature> curFeatures = backTmpComputer.Compute(_argumentProvider, aoiRect, filteredAOI);

            VertifyFirPixel(ref curFeatures, vertifyIndexiex, ref result);
            return(GetOtherExtractResult.GetExtractResult(_argumentProvider, curFeatures, result, _contextMessage, _progressTracker));
        }
Beispiel #23
0
        private void UpdateLayer(ResultObject resultObject)
        {
            IPixelIndexMapper  binaryValues = resultObject.BinaryValues;
            IBinaryBitampLayer binaryLayer  = resultObject.BinaryLayer;
            Bitmap             bitmap       = binaryLayer.Bitmap;

            using (IBinaryBitmapBuilder builder = new BinaryBitmapBuilder())
            {
                builder.Reset(bitmap.Size, ref bitmap);
                builder.Fill(binaryValues.Indexes.ToArray(), bitmap.Size, ref bitmap);
            }
            _canvasViewer.Canvas.Refresh(enumRefreshType.All);
        }
Beispiel #24
0
 private void CreateMapper(IArgumentProvider argProvider)
 {
     if (_candidateFirPixels != null)
     {
         _candidateFirPixels.Dispose();
     }
     if (_waitingFirPixels != null)
     {
         _waitingFirPixels.Dispose();
     }
     _candidateFirPixels = PixelIndexMapperFactory.CreatePixelIndexMapper("FIR", argProvider.DataProvider.Width, argProvider.DataProvider.Height, argProvider.DataProvider.CoordEnvelope, argProvider.DataProvider.SpatialRef);
     _waitingFirPixels   = PixelIndexMapperFactory.CreatePixelIndexMapper("FIR", argProvider.DataProvider.Width, argProvider.DataProvider.Height, argProvider.DataProvider.CoordEnvelope, argProvider.DataProvider.SpatialRef);
 }
Beispiel #25
0
        public override IExtractResult MakeExtProduct(IPixelIndexMapper piexd, Action <int, string> progressTracker)
        {
            IBandNameRaster             bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster;
            int                         visiBandNo     = TryGetBandNo(bandNameRaster, "Visible");
            int                         niBandNo       = TryGetBandNo(bandNameRaster, "NearInfrared");
            IPixelFeatureMapper <float> bpcd;

            using (IPixelFeatureMapper <float> ndvi = ComputeNDVIResult(_argumentProvider.DataProvider, piexd, visiBandNo, niBandNo))
            {
                bpcd = CreatPixelCoverRate(ndvi);
                bpcd.SetDispaly(false);
            }
            return(bpcd);
        }
Beispiel #26
0
        //魔术棒
        private void HandleAdsorb(object result)
        {
            GeometryOfDrawed    geometry = result as GeometryOfDrawed;
            IRasterDataProvider prd      = GetRasterDataProvider(_canvasViewer);

            using (IVectorAOIGenerator gen = new VectorAOIGenerator())
            {
                int[]             aoi    = gen.GetAOI(geometry.RasterPoints.Clone() as PointF[], geometry.Types, new Size(prd.Width, prd.Height));
                string            name   = GetName(_currentProduct, _currentSubProduct);
                IPixelIndexMapper mapper = _resultObjects[name].BinaryValues;
                mapper.Put(aoi);
                UpdateLayer(_resultObjects[name]);
            }
        }
Beispiel #27
0
 public void Extract(IPixelIndexMapper extractedPixels)
 {
     if (_infoExtracter == null || _boolFunc == null)
     {
         return;
     }
     _infoExtracter.VisitPixel(_visitBandNos, (idx, values) =>
     {
         if (_boolFunc(idx, values))
         {
             extractedPixels.Put(idx);
         }
     });
 }
Beispiel #28
0
        private unsafe IPixelIndexMapper CreataPixelMapper(string currDBLV, out List <int> vertifyIndexiex)
        {
            IPixelIndexMapper dblvInfo = null;

            vertifyIndexiex = new List <int>();
            using (IRasterDataProvider gd = GeoDataDriver.Open(currDBLV) as IRasterDataProvider)
            {
                string fiifFile = GetFirePointIndeiex.GetFireIndexiexFilename(currDBLV);
                dblvInfo = PixelIndexMapperFactory.CreatePixelIndexMapper("FIR", gd.Width, gd.Height, gd.CoordEnvelope, gd.SpatialRef);
                int[] indexiex = null;
                if (!string.IsNullOrEmpty(fiifFile))
                {
                    GetFirePointIndeiex.ReadFireIndexiexFilename(_argumentProvider, out indexiex);
                    dblvInfo.Put(indexiex);
                }
                Int16[]     dataBlock = new Int16[gd.Width * gd.Height];
                IRasterBand band      = gd.GetRasterBand(1);
                fixed(Int16 *buffer = dataBlock)
                {
                    IntPtr ptr = new IntPtr(buffer);

                    band.Read(0, 0, gd.Width, gd.Height, ptr, enumDataType.Int16, gd.Width, gd.Height);
                }

                int length = dataBlock.Length;
                if (string.IsNullOrEmpty(fiifFile))
                {
                    for (int i = 0; i < length; i++)
                    {
                        if (dataBlock[i] == (Int16)1)
                        {
                            dblvInfo.Put(i);
                            vertifyIndexiex.Add(i);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < length; i++)
                    {
                        if (dataBlock[i] == (Int16)1)
                        {
                            vertifyIndexiex.Add(i);
                        }
                    }
                }
            }
            return(dblvInfo);
        }
Beispiel #29
0
        //通过实时判识结果获取AOI
        private void 能见度计算_Click(object sender, EventArgs e)
        {
            InitExIdentify();
            _exAlg.CustomIdentify = "陆地";
            _exAlg.Satellite      = "FY3A";
            _exAlg.Sensor         = "VIRR";
            AlgorithmDef        alg = _sub.GetAlgorithmDefByIdentify("FY3Land");
            IArgumentProvider   arg = MonitoringThemeFactory.GetArgumentProvider(_exPro, _exAlg);
            IRasterDataProvider prd = GetRasterDataProviderVIRR();

            arg.DataProvider = prd;
            arg.AOI          = GetAOI(prd, true);
            arg.SetArg("FY3Land", alg);
            SubProductBinaryDst bin    = new SubProductBinaryDst(_sub);
            IPixelIndexMapper   result = bin.Make(null) as IPixelIndexMapper;

            int[] indxs = result.Indexes.ToArray();

            _exPro.SubProductIdentify = "VISY";
            _sub = _pro.GetSubProductDefByIdentify("VISY");
            _exAlg.CustomIdentify = null;
            AlgorithmDef      visiAlg = _sub.GetAlgorithmDefByIdentify("Visibility");
            IArgumentProvider visiArg = MonitoringThemeFactory.GetArgumentProvider(_exPro, _exAlg);

            visiArg.DataProvider = prd;
            visiArg.AOI          = indxs;
            visiArg.SetArg("Visibility", visiAlg);
            SubProductRasterDst          raster       = new SubProductRasterDst(_sub);
            IPixelFeatureMapper <UInt16> rasterResult = raster.Make(null) as IPixelFeatureMapper <UInt16>;

            //
            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(rasterResult);
            iir.Dispose();

            MessageBox.Show("能见度计算完成!");
        }
Beispiel #30
0
 private int[] GetPreExtractIndex()
 {
     if (_argumentProvider.EnvironmentVarProvider is IMonitoringSession)
     {
         IMonitoringSession mSession = _argumentProvider.EnvironmentVarProvider as IMonitoringSession;
         if (mSession.ExtractingSession != null)
         {
             IPixelIndexMapper preExtract = mSession.ExtractingSession.GetBinaryValuesMapper("FIR", "DBLV");
             if (preExtract != null && preExtract.Indexes != null)
             {
                 return(preExtract.Indexes.ToArray());
             }
         }
     }
     return(null);
 }