private unsafe void button5_Click(object sender, EventArgs e) { //先生成全文件NDVI文件 string fname = @"E:\数据文件\蓝藻\th_2012_05_05_02_44_GZ.ld2"; IRasterDataProvider dataProvider = GeoDataDriver.Open(fname) as IRasterDataProvider; IPixelFeatureMapper <float> ndvi = new MemPixelFeatureMapper <float>("NDVI_Temp", 1000, new Size(dataProvider.Width, dataProvider.Height), dataProvider.CoordEnvelope, dataProvider.SpatialRef); IArgumentProvider argprdNDVI = new ArgumentProvider(dataProvider, null); //argprdNDVI.AOI = idxs; string expressNDVI = "(band2 - band1) / (float)(band2 + band1)"; int[] bandNos = new int[] { 1, 2 }; //构造栅格计算判识器 IRasterExtracter <UInt16, float> extracterNDVI = new SimpleRasterExtracter <UInt16, float>(); extracterNDVI.Reset(argprdNDVI, bandNos, expressNDVI); //判识 extracterNDVI.Extract(ndvi); //NDVI结果永久保存 RasterIdentify idNDVI = new RasterIdentify(); idNDVI.ThemeIdentify = "CMA"; idNDVI.ProductIdentify = "BAG"; idNDVI.SubProductIdentify = "NDVITemp"; idNDVI.OrbitDateTime = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0)); idNDVI.GenerateDateTime = DateTime.Now; //NDVISetValue setValue = new NDVISetValue(0.17f, 0.8f); //int size = sizeof(NDVISetValue); IInterestedRaster <float> iirNDVI = new InterestedRaster <float>(idNDVI, new Size(dataProvider.Width, dataProvider.Height), dataProvider.CoordEnvelope.Clone(), dataProvider.SpatialRef); //iirNDVI.SetExtHeader(setValue); iirNDVI.Put(ndvi); iirNDVI.Dispose(); }
private void button14_Click(object sender, EventArgs e) { //构造参数提供者 string fname = @"f:\\FY3A_Mersi_2010_06_24_10_00_1000M_L1B_PRJ_Whole.LDF"; IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider; ArgumentProvider argprd = new ArgumentProvider(prd, null); //构造判识表达式 //string express = "(band4 + band3) == 0? 0f : (band4 - band3) / (float)(band4 + band3)"; string express = "NDVI(band4,band3)"; int[] bandNos = new int[] { 4, 3 }; //构造栅格计算判识器 IRasterExtracter <UInt16, float> extracter = new SimpleRasterExtracter <UInt16, float>(); extracter.Reset(argprd, bandNos, express); //判识 resultNDVI = new MemPixelFeatureMapper <float>("NDVI", 1000, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef); Stopwatch sw = new Stopwatch(); sw.Start(); extracter.Extract(resultNDVI); //sw.Stop(); //Text = sw.ElapsedMilliseconds.ToString(); //判识结果生成二值位图 //IBinaryBitmapBuilder builder = new BinaryBitmapBuilder(); //Size bmSize = new Size(prd.Width / 2, prd.Height / 2); //Bitmap bitmap = builder.CreateBinaryBitmap(bmSize, Color.Red, Color.Transparent); //builder.Fill(idxs, new Size(prd.Width, prd.Height), ref bitmap); //bitmap.Save("f:\\1.png", ImageFormat.Png); //判识结果永久保存 RasterIdentify id = new RasterIdentify(); id.ThemeIdentify = "CMA"; id.ProductIdentify = "FIR"; id.SubProductIdentify = "NDVI"; id.Satellite = "FY3A"; id.Sensor = "MERSI"; id.Resolution = "250M"; id.OrbitDateTime = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0)); id.GenerateDateTime = DateTime.Now; IInterestedRaster <float> iir = new InterestedRaster <float>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone()); iir.Put(resultNDVI); iir.Dispose(); sw.Stop(); Text = sw.ElapsedMilliseconds.ToString(); int count = iir.Count(aoi, (v) => { return(v == 1); }); iir.Count(aoi, (v) => { return((int)v); }); }
private void button16_Click(object sender, EventArgs e) { using (VectorAOITemplate v = VectorAOITemplateFactory.GetAOITemplate("贝尔湖")) //贝尔湖 { Size size; IRasterDataProvider prd; Envelope evp = GetEnvelope(out size, out prd); Stopwatch sw = new Stopwatch(); sw.Start(); aoi = v.GetAOI(evp, size); // int[] reverseAOI = AOIHelper.Reverse(aoi, size); IBinaryBitmapBuilder b = new BinaryBitmapBuilder(); Bitmap bm = b.CreateBinaryBitmap(size, Color.Red, Color.Black); b.Fill(reverseAOI, size, ref bm); // string express = "NDVI(band1,band2)"; int[] bandNos = new int[] { 1, 2 }; //构造栅格计算判识器 ArgumentProvider argprd = new ArgumentProvider(prd, null); argprd.AOI = aoi; IRasterExtracter <UInt16, float> extracter = new SimpleRasterExtracter <UInt16, float>(); extracter.Reset(argprd, bandNos, express); //判识 resultNDVI = new MemPixelFeatureMapper <float>("NDVI", 1000, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef); extracter.Extract(resultNDVI); // RasterIdentify id = new RasterIdentify(); id.ThemeIdentify = "CMA"; id.ProductIdentify = "FIR"; id.SubProductIdentify = "NDVI"; id.Satellite = "FY3A"; id.Sensor = "MERSI"; id.Resolution = "250M"; id.OrbitDateTime = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0)); id.GenerateDateTime = DateTime.Now; IInterestedRaster <float> iir = new InterestedRaster <float>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone()); iir.Put(resultNDVI); iir.Dispose(); } }
// public IExtractResult ComputeByCurrentRaster(Action <int, string> progressTracker) { if (_argumentProvider == null || _argumentProvider.DataProvider == null) { return(null); } if (_arg == null) { return(null); } int[] bandNos = _arg.BandNos; string express = _arg.Express; IRasterExtracter <UInt16, Int16> extracter = new SimpleRasterExtracter <UInt16, Int16>(); extracter.Reset(_argumentProvider, bandNos, express); IRasterDataProvider prd = _argumentProvider.DataProvider; IPixelFeatureMapper <Int16> result = new MemPixelFeatureMapper <Int16>(_identify, prd.Width * prd.Height, new System.Drawing.Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef); extracter.Extract(result); return(result); }
public IExtractResult ComputeByFiles(string[] fnames) { if (_arg == null) { return(null); } IExtractResultArray resultAry = new ExtractResultArray(_identify); IRasterExtracter <UInt16, Int16> extracter = new SimpleRasterExtracter <UInt16, Int16>(); foreach (string fname in fnames) { if (!IsSameTypeFile(fname)) { continue; } IExtractResultBase result = ComputeSingleFile(fname, extracter, _arg.BandNos, _arg.Express); if (result != null) { resultAry.Add(result); } } return(resultAry); }
private IExtractResult ComputeVisibility() { if (_argumentProvider.DataProvider == null) { PrintInfo("请提供沙尘影像数据!"); return(null); } IRasterDataProvider prd = _argumentProvider.DataProvider; int[] aois = GetAOIByBinaryFile(); if (aois != null && aois.Length != 0) { _argumentProvider.AOI = aois; } int visiNo = -1, nearNo = -1, shortNo = -1, farNo = -1; IBandNameRaster bandNameRaster = _argumentProvider.DataProvider as IBandNameRaster; // visiNo = TryGetBandNo(bandNameRaster, "Visible"); //(int)_argumentProvider.GetArg("Visible"); nearNo = TryGetBandNo(bandNameRaster, "NearInfrared"); //(int)_argumentProvider.GetArg("NearInfrared"); shortNo = TryGetBandNo(bandNameRaster, "ShortInfrared"); //(int)_argumentProvider.GetArg("ShortInfrared"); farNo = TryGetBandNo(bandNameRaster, "FarInfrared"); //(int)_argumentProvider.GetArg("FarInfrared"); double visiZoom = (double)_argumentProvider.GetArg("Visible_Zoom"); double nearZoom = (double)_argumentProvider.GetArg("NearInfrared_Zoom"); double shortZoom = (double)_argumentProvider.GetArg("ShortInfrared_Zoom"); double farZoom = (double)_argumentProvider.GetArg("FarInfrared_Zoom"); if (visiNo == -1 || nearNo == -1 || shortNo == -1 || farNo == -1 || visiZoom == -1 || farZoom == -1 || shortZoom == -1) { PrintInfo("获取波段序号失败,可能是波段映射表配置错误或判识算法波段参数配置错误。"); return(null); } int bandCount = prd.BandCount; if (visiNo > bandCount) { PrintInfo("可见光波段序号超过数据的波段范围,可能是影像数据选择不正确。"); return(null); } if (nearNo > bandCount) { PrintInfo("近红外波段序号超过数据的波段范围,可能是影像数据选择不正确。"); return(null); } if (shortNo > bandCount) { PrintInfo("短波红外波段序号超过数据的波段范围,可能是影像数据选择不正确。"); return(null); } if (farNo > bandCount) { PrintInfo("远红外波段序号超过数据的波段范围,可能是影像数据选择不正确。"); return(null); } int[] bandNos = new int[] { visiNo, nearNo, shortNo, farNo }; string express = "(UInt16)Math.Round(1000 * Math.Pow(Math.E,(var_VisibilityA + var_VisibilityB * band" + visiNo + " / " + visiZoom + "f + var_VisibilityC * band" + nearNo + "/" + nearZoom + "f + var_VisibilityD * band" + shortNo + "/" + shortZoom + "f + var_VisibilityE * band" + farNo + "/" + farZoom + "f + var_VisibilityF *(band" + shortNo + "/" + shortZoom + "f - band" + farNo + "/" + farZoom + "f + var_ShortFarVar))),0)"; IRasterExtracter <UInt16, UInt16> extracter = new SimpleRasterExtracter <UInt16, UInt16>(); extracter.Reset(_argumentProvider, bandNos, express); IPixelFeatureMapper <UInt16> result = new MemPixelFeatureMapper <UInt16>("Visibility", 1000, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef); extracter.Extract(result); return(result); }
private void 沙尘能见度_Click(object sender, EventArgs e) { //首先进行沙尘判识,得出判识出的沙尘区域 string fname = @"E:\第二张盘\01_沙尘\2011年04月30日\FY3A_VIRRX_GBAL_L1_20110430_0305_1000M_MS_PRJ_DXX.LDF"; //Dictionary<string, object> args = new Dictionary<string, object>(); //args.Add("a", 28); //args.Add("b", 78); //args.Add("c", 245); //args.Add("d", 293); //args.Add("f", 0); //args.Add("g", 20); //args.Add("h", 15); //args.Add("i", 250); IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider; //ArgumentsProvider argprd = new ArgumentsProvider(prd, args); //string extractExpress = "((band2/10f) > var_a) && (band2/10f < var_b) && (band5/10f > var_c) && (band5/10f < var_d) && " // + "(band6/10f > var_a) && ((band6 - band2)>var_f) && ((band6/10f - band5/10f + var_i)>var_h)"; //band2:可见光,0.525~0.575(波长范围) //band5:远红外,10.3~11.55 //band6:短波红外,1.60~1.69 //int[] exBandNos = new int[] { 2, 5, 6 }; //IThresholdExtracter<UInt16> thrExtracter = new SimpleThresholdExtracter<UInt16>(); //thrExtracter.Reset(argprd, exBandNos, extractExpress); //extractResult = new MemPixelIndexMapper("SAND", 1000); //thrExtracter.Extract(extractResult); //idxs = extractResult.Indexes.ToArray(); //获取到判识结果 //将判识结果作为AOI传入进行能见度计算 string express = "(UInt16)Math.Round(1000 * Math.Pow(Math.E,(var_visibleA + var_visibleB * band1/10f + var_visibleC * band2/10f + var_visibleD * band6/10f + var_visibleE * band4/10f + var_visibleF *(band6/10f - band4/10f + var_shortFar))),0)"; //express = " 80 "; //string express = "1000*Math.Pow(Math.E,(44.7603 +0.181571 * band2/10f -0.332972 * band4/10f + 0.122736 * band6/10f -0.144287 * band5/10f -0.114465 *(band6/10f - band5/10f + 253)))"; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("visibleA", 44.7603); args.Add("visibleB", 0.181571); args.Add("visibleC", -0.332972); args.Add("visibleD", 0.122736); args.Add("visibleE", -0.144287); args.Add("visibleF", -0.114465); args.Add("shortFar", 253); int[] bandNos = new int[] { 1, 2, 6, 4 }; ArgumentProvider argProvider = new ArgumentProvider(prd, args); //argProvider.AOI = idxs; IRasterExtracter <UInt16, UInt16> extracter = new SimpleRasterExtracter <UInt16, UInt16>(); extracter.Reset(argProvider, bandNos, express); result = new MemPixelFeatureMapper <UInt16>("Visibility", 1000, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef); Stopwatch sw = new Stopwatch(); sw.Start(); extracter.Extract(result); RasterIdentify id = new RasterIdentify(); id.ThemeIdentify = "CMA"; id.ProductIdentify = "SAND"; id.SubProductIdentify = "VISIBILITY"; id.Satellite = "FY3A"; id.Sensor = "VIRRX"; id.Resolution = "1000M"; id.OrbitDateTime = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0)); id.GenerateDateTime = DateTime.Now; IInterestedRaster <UInt16> iir = new InterestedRaster <UInt16>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone()); iir.Put(result); iir.Dispose(); sw.Stop(); Text = sw.ElapsedMilliseconds.ToString(); }